Package: knetload
Version: 2.3-3.1
Severity: important
Tags: patch

Some kernels use 64-bit counters for network traffic.  This means
/sys/class/net/*/statistics/[rt]x_bytes can contain a number that
doesn't fit in an unsigned int.

The attached patch fixes this by reading the counter into a 64-bit
variable.  I've truncated this to 32 bits before assigning to currIn/currOut
so it wraps properly and remains accurate with large traffic counts
(currIn/currOut are only single precision floats).

The %Ld scanf format specificer is glibc specific, but that should be ok
because this is linux only code.

Tested with i386 userland on x86_64 kenrel.

Paul

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15-rc6-w64
Locale: LANG=en_GB, LC_CTYPE=en_GB (charmap=ISO-8859-1)

Versions of packages knetload depends on:
ii  kdelibs4c2a              4:3.4.3-2       core libraries for all KDE applica
ii  libart-2.0-2             2.3.17-1        Library of functions for 2D graphi
ii  libaudio2                1.7-3           The Network Audio System (NAS). (s
ii  libc6                    2.3.5-9         GNU C Library: Shared libraries an
ii  libfontconfig1           2.3.2-1.1       generic font configuration library
ii  libfreetype6             2.1.10-1        FreeType 2 font engine, shared lib
ii  libice6                  6.8.2.dfsg.1-11 Inter-Client Exchange library
ii  libidn11                 0.5.18-1        GNU libidn library, implementation
ii  libjpeg62                6b-11           The Independent JPEG Group's JPEG 
ii  libpng12-0               1.2.8rel-5      PNG library - runtime
ii  libqt3-mt                3:3.3.5-3       Qt GUI Library (Threaded runtime v
ii  libsm6                   6.8.2.dfsg.1-11 X Window System Session Management
ii  libx11-6                 6.8.2.dfsg.1-11 X Window System protocol client li
ii  libxcursor1              1.1.3-1         X cursor management library
ii  libxext6                 6.8.2.dfsg.1-11 X Window System miscellaneous exte
ii  libxft2                  2.1.7-1         FreeType-based font drawing librar
ii  libxi6                   6.8.2.dfsg.1-11 X Window System Input extension li
ii  libxinerama1             6.8.2.dfsg.1-11 X Window System multi-head display
ii  libxrandr2               6.8.2.dfsg.1-11 X Window System Resize, Rotate and
ii  libxrender1              1:0.9.0-2       X Rendering Extension client libra
ii  libxt6                   6.8.2.dfsg.1-11 X Toolkit Intrinsics
ii  zlib1g                   1:1.2.3-9       compression library - runtime

Versions of packages knetload recommends:
ii  kicker                        4:3.4.3-3  desktop panel for KDE

-- no debconf information
diff -ur knetload-2.3/knetload/knetproc.cpp clean/knetload/knetproc.cpp
--- knetload-2.3/knetload/knetproc.cpp	2005-12-29 19:46:38.000000000 +0000
+++ clean/knetload/knetproc.cpp	2004-07-01 12:48:00.000000000 +0100
@@ -157,15 +157,15 @@
 #ifdef Q_OS_LINUX
     static FILE* fd;
     
-    static unsigned long long tmp;
+    static unsigned int tmp;
     static char *fn;
     asprintf(&fn, "/sys/class/net/%s/statistics/rx_bytes", device.latin1());
     
     if ( (fd = fopen(fn, "r")) == 0 )
         return;
 
-    fscanf(fd, "%Lu", &tmp);
-    currIn = (unsigned int)tmp;
+    fscanf(fd, "%u", &tmp);
+    currIn = tmp;
 
     fclose(fd);
     fn[strlen(fn)-8] = 't'; // "/sys/class/net/%s/statistics/tx_bytes"
@@ -173,8 +173,8 @@
     if ( (fd = fopen(fn, "r")) == 0 )
         return;
 
-    fscanf(fd, "%Lu", &tmp);
-    currOut = (unsigned int)tmp;
+    fscanf(fd, "%u", &tmp);
+    currOut = tmp;
     
     fclose(fd);
     free(fn);

Reply via email to