Package: nicstat
Version: 1.92-1
Tags: patch

On Linux, when nicstat obtains nic info via ioctl SIOCETHTOOL, it picks
up the speed from a struct ethtool_cmd, where it's stored as a u16 in
Mbps, and multiplies it by the integer literal 1000000 to get bps.

On 10GbE ethernet this causes a signed integer overflow, which is
undefined behaviour and the result sadly never seems to work out to
the correct 10,000,000,000 bps :-)


diff --git a/nicstat.c b/nicstat.c
index 3b028d7..579501d 100644
--- a/nicstat.c
+++ b/nicstat.c
@@ -1585,7 +1585,7 @@ get_speed_duplex(nicdata_t *nicp)
                get_speed_duplex(nicp);
                return;
        }
-       nicp->speed = edata.speed * 1000000;
+       nicp->speed = (uint64_t)edata.speed * 1000000;
        nicp->duplex = edata.duplex;
 }
 #endif /* OS_LINUX */


Thanks,

-- 
Stelios.


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to