bin/166483: if_nametoindex sends un-initialized bytes to ioctl

Roy Marples roy at marples.name
Thu Mar 29 09:00:23 UTC 2012


>Number:         166483
>Category:       bin
>Synopsis:       if_nametoindex sends un-initialized bytes to ioctl
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 29 09:00:22 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Roy Marples
>Release:        7.1
>Organization:
>Environment:
[roy at uberlaptop /usr/home/roy]$ uname -a
FreeBSD uberlaptop 7.1-RELEASE-p2 FreeBSD 7.1-RELEASE-p2 #3: Mon Feb  9 17:12:55 GMT 2009     root at uberlaptop:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
if_nametoindex(3) sends un-initialized bytes to ioctl

I found this when I was fixing BSD specific memory issues with dhcpcd.
With the below patch to libc applied, dhcpcd-5.5.6 runs flawlessly without any errors reported by Valgrind.
>How-To-Repeat:

>Fix:



Patch attached with submission follows:

--- if_nametoindex.c.orig	2012-03-28 20:14:38.000000000 +0100
+++ if_nametoindex.c	2012-03-28 20:15:20.000000000 +0100
@@ -70,6 +70,7 @@
 
 	s = _socket(AF_INET, SOCK_DGRAM, 0);
 	if (s != -1) {
+		memset(&ifr, 0, sizeof(ifr));
 		strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
 		if (_ioctl(s, SIOCGIFINDEX, &ifr) != -1) {
 			_close(s);


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list