[Pkg-wmaker-commits] [wmifs] 04/118: wmifs: Prevent crash when too many devices.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Thu Aug 27 02:37:46 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmifs.

commit 786b6fe0ff9fa023a63158f8152a24ba1106291b
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date:   Wed Oct 22 16:34:32 2014 -0500

    wmifs: Prevent crash when too many devices.
    
    Patch by Chris Hanson <cph at martigny.ai.mit.edu>.  First appeared in Debian
    package 1.3b1-6.
    
    From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=39922:
    wmifs crashes with a cryptic X error message when there are more than
    4 net devices.  This occurs for me because I install vmware, which
    installs 4 network devices for its bridging hack.
    
    The bug is a loop that fills a fixed-length array, but doesn't stop
    when the array is full.  The fix is to add a conditional break to the
    loop.  A patch appears below.
    
    I made two additional changes: (1) increased the size of the array,
    and (2) changed a name comparison to compare all of the characters of
    the name, rather than just the visible characters, since there may be
    multiple net devices with the same first 4 characters (vmware does
    this, too).
---
 wmifs/wmifs.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/wmifs/wmifs.c b/wmifs/wmifs.c
index 52ea3e5..aaaf846 100644
--- a/wmifs/wmifs.c
+++ b/wmifs/wmifs.c
@@ -306,7 +306,7 @@ int main(int argc, char *argv[]) {
 |* wmifs_routine															   *|
 \*******************************************************************************/
 
-#define MAX_STAT_DEVICES 4
+#define MAX_STAT_DEVICES 16
 
 typedef struct {
 
@@ -485,7 +485,7 @@ void wmifs_routine(int argc, char **argv) {
 						stat_online = checknetdevs();
 						stat_current = 0;
 						for (i=0; i<stat_online; i++) {
-							if (!strncmp(temp, stat_devices[i].name, 4)) {
+							if (!strcmp(temp, stat_devices[i].name)) {
 								stat_current = i;
 							}
 						}
@@ -718,6 +718,8 @@ int checknetdevs(void) {
 				strcpy(foundbuffer[devsfound], p);
 				devsfound++;
 			}
+			if (devsfound >= MAX_STAT_DEVICES)
+				break;
 		}
 		fclose(fd);
 	}
@@ -739,7 +741,7 @@ int checknetdevs(void) {
 		}
 	}
 
-	for (i=0, j=0; j<MAX_STAT_DEVICES; i++) {
+	for (i=0, j=0; j<MAX_STAT_DEVICES; i++, j++) {
 
 		while (!stat_devices[j].name[0] && j < MAX_STAT_DEVICES)
 			j++;
@@ -747,8 +749,6 @@ int checknetdevs(void) {
 		if (j < MAX_STAT_DEVICES && i != j) {
 			stat_devices[i] = stat_devices[j];
 		}
-		
-		j++;
 	}
 	i--;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmifs.git



More information about the Pkg-wmaker-commits mailing list