diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-22 18:33:50 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-22 18:35:52 +0200 |
commit | b4cef2524f3b2be11f905c4114e2e747a8101160 (patch) | |
tree | 3bd95e4ce54c72edc8cbf5d0eb9cf7202048bebd /tun_linux.go | |
parent | 7038de95e119147245741c04feab25b833b615e9 (diff) |
Fix integer conversions
Diffstat (limited to 'tun_linux.go')
-rw-r--r-- | tun_linux.go | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/tun_linux.go b/tun_linux.go index b43ded8..db9cb51 100644 --- a/tun_linux.go +++ b/tun_linux.go @@ -263,13 +263,7 @@ func (tun *NativeTun) MTU() (int, error) { return 0, errors.New("failed to get MTU of TUN device: " + strconv.FormatInt(int64(errno), 10)) } - // convert result to signed 32-bit int - - val := binary.LittleEndian.Uint32(ifr[16:20]) - if val >= (1 << 31) { - return int(toInt32(val)), nil - } - return int(val), nil + return int(*(*int32)(unsafe.Pointer(&ifr[16]))), nil } func (tun *NativeTun) Name() (string, error) { |