[BusyBox-cvs] busybox.stable/libbb interface.c,1.7,1.8

Erik Andersen andersen at busybox.net
Mon Jul 28 06:37:08 UTC 2003


Update of /var/cvs/busybox.stable/libbb
In directory winder:/tmp/cvs-serv27222/libbb

Modified Files:
	interface.c 
Log Message:
James Petterson writes:

I've found a possible bug in libbb/interface.c, in function
if_readlist_proc(). This function calls get_name(), and passes
as an argument 'name', a buffer of 16 bytes (IFNAMSIZ).  The
function get_name(), however, may use more than 16 bytes,
when it is searching for aliases. Even if you don't have an
alias interface, you can run into trouble if the interface
has received more than 99999999 bytes, in which case the
space between the interface name and the rx stats
disappears, as in the /proc/net/dev example below:
 wan0.200:264573315  462080    ...
In this case get_name() correctly identifies the interface name
as "wan0.200", but to do that it uses 18 bytes of the 'name'
buffer, which could lead to an unpredictable error.

A simple solution would be to increase the size of the buffer:



Index: interface.c
===================================================================
RCS file: /var/cvs/busybox.stable/libbb/interface.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- interface.c	17 Sep 2002 06:36:56 -0000	1.7
+++ interface.c	28 Jul 2003 06:37:04 -0000	1.8
@@ -1269,7 +1269,7 @@
 
     err = 0;
     while (fgets(buf, sizeof buf, fh)) {
-	char *s, name[IFNAMSIZ];
+	char *s, name[128];
 	s = get_name(name, buf);    
 	ife = add_interface(name);
 	get_dev_fields(s, ife);




More information about the busybox-cvs mailing list