From 3bd48a06c5d35d25b6b72d48cb2df5ca4873ec5a Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Wed, 22 Oct 2014 16:34:29 -0500 Subject: [PATCH] wmifs: Add BUFFER_SIZE constant. Patch by Stephen Pitts . First appeared in Debian package version 1.3b1-4. From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=41746: wmifs started crashing on startup on my system, so I grabbed the source, added -g to the Makefile, and ran it through gdb. (Wow, the wonders of Open Source!!). I found out that it has the hard-coded assumption that a line in /proc/net/dev will be no longer than 128 bytes. Since my ethernet card has over 1 GB in traffic , my eth0 line was 129 bytes long. I added a new constant, BUFFER_SIZE, that determines the size of the buffer used for fgets. Right now, its at 512 bytes, so that gives it a large margin of error, until we have petabyte Ethernet! The patch is attached. --- wmifs/wmifs/wmifs.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/wmifs/wmifs/wmifs.c b/wmifs/wmifs/wmifs.c index ebdf12b..f7df9b7 100644 --- a/wmifs/wmifs/wmifs.c +++ b/wmifs/wmifs/wmifs.c @@ -74,6 +74,11 @@ ---- Changes: --- + 07/21/1999 (Stephen Pitts, smpitts@midsouth.rr.com) + * Added new constant: BUFFER_SIZE to determine the size + of the buffer used in fgets() operations. Right now, + its at 512 bytes. Fixed crashing on my system when + one line of /proc/net/dev was longer than 128 bytes 04/05/1998 (Martijn Pieterse, pieterse@xs4all.nl) * Changed the "middle of the waveform" line color * Moved the RedrawWindow out of the main loop. @@ -197,6 +202,8 @@ #define WMIFS_VERSION "1.2.1" +/* the size of the buffer read from /proc/net/* */ +#define BUFFER_SIZE 512 /**********************/ /* External Variables */ /**********************/ @@ -340,7 +347,7 @@ void wmifs_routine(int argc, char **argv) { long ipacket, opacket, istat, ostat; - char temp[128]; + char temp[BUFFER_SIZE]; char *p; for (i=0; i