File: 729895.patch

package info (click to toggle)
nicstat 1.95-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, jessie, jessie-kfreebsd, sid, stretch, trixie
  • size: 448 kB
  • ctags: 905
  • sloc: ansic: 8,988; sh: 194; makefile: 11
file content (21 lines) | stat: -rw-r--r-- 819 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Description: fix miscalculation of NIC speed
 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 :-)
Author: Stelios Bounanos <dbts@enotty.net>
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=729895
--- a/nicstat.c
+++ b/nicstat.c
@@ -1609,7 +1609,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 */