rpms/net-tools/devel net-tools-1.60-interface_stack.patch, NONE, 1.1 net-tools-1.60-hostname_man.patch, 1.1, 1.2 net-tools.spec, 1.50, 1.51

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Mon Jan 2 10:00:57 UTC 2006


Author: rvokal

Update of /cvs/dist/rpms/net-tools/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv21326

Modified Files:
	net-tools-1.60-hostname_man.patch net-tools.spec 
Added Files:
	net-tools-1.60-interface_stack.patch 
Log Message:
- clear static buffers in interface.c by <drepper at redhat.com> (#176714)

net-tools-1.60-interface_stack.patch:
 interface.c |   43 ++++++++++++++++++++++++++++---------------
 1 files changed, 28 insertions(+), 15 deletions(-)

--- NEW FILE net-tools-1.60-interface_stack.patch ---
Bugzilla Bug 176714 – *** stack smashing detected ***: /sbin/ifconfig terminated

--- lib/interface.c-old	2005-12-30 11:08:15.000000000 -0800
+++ lib/interface.c	2005-12-30 11:17:02.000000000 -0800
@@ -201,10 +201,11 @@
     return err;
 }
 
-static char *get_name(char *name, char *p)
+static char *get_name(char **namep, char *p)
 {
     while (isspace(*p))
 	p++;
+    char *name = *namep = p;
     while (*p) {
 	if (isspace(*p))
 	    break;
@@ -305,9 +306,10 @@
 {
     static int proc_read; 
     FILE *fh;
-    char buf[512];
     struct interface *ife;
     int err;
+    char *line = NULL;
+    size_t linelen = 0;
 
     if (proc_read) 
 	    return 0; 
@@ -320,8 +322,11 @@
 			_PATH_PROCNET_DEV, strerror(errno)); 
 		return if_readconf();
 	}	
-    fgets(buf, sizeof buf, fh);	/* eat line */
-    fgets(buf, sizeof buf, fh);
+    if (getline(&line, &linelen, fh) == -1 /* eat line */
+	|| getline(&line, &linelen, fh) == -1) {
+		err = -1;
+		goto out;
+    }
 
 #if 0				/* pretty, but can't cope with missing fields */
     fmt = proc_gen_fmt(_PATH_PROCNET_DEV, 1, fh,
@@ -346,13 +351,13 @@
     if (!fmt)
 	return -1;
 #else
-    procnetdev_vsn = procnetdev_version(buf);
+    procnetdev_vsn = procnetdev_version(line);
 #endif
 
     err = 0;
-    while (fgets(buf, sizeof buf, fh)) {
-	char *s, name[IFNAMSIZ];
-	s = get_name(name, buf);    
+    while (getline(&line, &linelen, fh) != -1) {
+	char *s, *name;
+	s = get_name(&name, line);    
 	ife = add_interface(name);
 	get_dev_fields(s, ife);
 	ife->statistics_valid = 1;
@@ -368,6 +373,8 @@
 #if 0
     free(fmt);
 #endif
+  out:
+    free(line);
     fclose(fh);
     return err;
 }
@@ -376,8 +383,9 @@
 static int if_readlist_rep(char *target, struct interface *ife)
 {
     FILE *fh;
-    char buf[512];
     int err;
+    char *line = NULL;
+    size_t linelen = 0;
 
     fh = fopen(_PATH_PROCNET_DEV, "r");
     if (!fh) {
@@ -385,15 +393,18 @@
 			_PATH_PROCNET_DEV, strerror(errno)); 
 		return if_readconf();
 	}	
-    fgets(buf, sizeof buf, fh);	/* eat line */
-    fgets(buf, sizeof buf, fh);
+    if (getline(&line, &linelen, fh) == -1 /* eat line */
+	|| getline(&line, &linelen, fh) == -1) {
+		err = -1;
+		goto out;
+    }
 
-    procnetdev_vsn = procnetdev_version(buf);
+    procnetdev_vsn = procnetdev_version(line);
 
     err = 0;
-    while (fgets(buf, sizeof buf, fh)) {
-	char *s, name[IFNAMSIZ];
-	s = get_name(name, buf);    
+    while (getline(&line, &linelen, fh) != -1) {
+	char *s, *name;
+	s = get_name(&name, line);    
 	get_dev_fields(s, ife);
 	if (target && !strcmp(target,name))
 	{
@@ -406,6 +417,8 @@
 	err = -1;
     }
 
+  out:
+    free(line);
     fclose(fh);
     return err;
 }

net-tools-1.60-hostname_man.patch:
 hostname.1 |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+)

Index: net-tools-1.60-hostname_man.patch
===================================================================
RCS file: /cvs/dist/rpms/net-tools/devel/net-tools-1.60-hostname_man.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- net-tools-1.60-hostname_man.patch	15 Oct 2005 09:53:21 -0000	1.1
+++ net-tools-1.60-hostname_man.patch	2 Jan 2006 10:00:42 -0000	1.2
@@ -10,13 +10,13 @@
 +is used to get the hostname.  Only when the 
 +.BR "hostname \-s" 
 +is called will 
-+.BR gethostbyname(2)
++.BR gethostbyname(3)
 +be called.  The difference in 
 +.BR gethostname(2)
 +and
-+.BR gethostbyname(2)
++.BR gethostbyname(3)
 +is that
-+.BR gethostbyname(2)
++.BR gethostbyname(3)
 +is network aware, so it consults 
 +.IR /etc/nsswitch.conf
 +and


Index: net-tools.spec
===================================================================
RCS file: /cvs/dist/rpms/net-tools/devel/net-tools.spec,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- net-tools.spec	9 Dec 2005 22:42:19 -0000	1.50
+++ net-tools.spec	2 Jan 2006 10:00:42 -0000	1.51
@@ -3,7 +3,7 @@
 Summary: Basic networking tools.
 Name: net-tools
 Version: 1.60
-Release: 57.1
+Release: 58
 License: GPL
 Group: System Environment/Base
 Source0: http://www.tazenda.demon.co.uk/phil/net-tools/net-tools-%{version}.tar.bz2
@@ -56,6 +56,7 @@
 Patch42: net-tools-1.60-ifconfig.patch
 Patch43: net-tools-1.60-arp_overflow.patch
 Patch44: net-tools-1.60-hostname_man.patch
+Patch45: net-tools-1.60-interface_stack.patch
 
 BuildRoot: %{_tmppath}/%{name}-root
 Requires(post,preun): chkconfig
@@ -108,6 +109,7 @@
 %patch42 -p1 -b .iface_drop
 %patch43 -p1 -b .overflow
 %patch44 -p1 -b .hostname_man
+%patch45 -p0 -b .stack
 
 cp %SOURCE2 ./config.h
 cp %SOURCE3 ./config.make
@@ -219,6 +221,9 @@
 %{_sysconfdir}/rc.d/init.d/netplugd
 
 %changelog
+* Mon Jan 02 2006 Radek Vokal <rvokal at redhat.com> 1.60-58
+- clear static buffers in interface.c by <drepper at redhat.com> (#176714)
+
 * Fri Dec 09 2005 Jesse Keating <jkeating at redhat.com>
 - rebuilt
 




More information about the fedora-cvs-commits mailing list