__ifreq() bug in current cvs
Jakub Bogusz
qboosh@pld-linux.org
Mon Jul 26 15:23:00 GMT 2004
After last memory handling fix in libc/sysdeps/unix/sysv/linux/ifreq.c,
__ifreq() doesn't return proper data in buffer - because after realloc
__ioctl is called on old buffer (NULL in most cases).
Userland testcase can be e.g. "hostname -d" with "reorder on" in
host.conf - __ifreq bug triggers assert in res_hconf.c:589, when
realloc() returns NULL because 0 usable interfaces were found.
One of possible ways to fix is attached.
--
Jakub Bogusz http://cyber.cs.net.pl/~qboosh/
-------------- next part --------------
--- libc/sysdeps/unix/sysv/linux/ifreq.c.orig Fri May 7 05:57:37 2004
+++ libc/sysdeps/unix/sysv/linux/ifreq.c Mon Jul 26 13:58:08 2004
@@ -71,6 +71,8 @@
{
ifc.ifc_len = rq_len;
void *newp = realloc (ifc.ifc_buf, ifc.ifc_len);
+ if (newp != NULL)
+ ifc.ifc_buf = newp;
if (newp == NULL || __ioctl (fd, SIOCGIFCONF, &ifc) < 0)
{
free (ifc.ifc_buf);
@@ -82,7 +84,6 @@
*ifreqs = NULL;
return;
}
- ifc.ifc_buf = newp;
if (!old_siocgifconf || ifc.ifc_len < rq_len)
break;
More information about the Libc-alpha
mailing list