Subject: sys/net/if.c ifconf() doesn't handle > 10 interfaces of the same type
To: None <freebsd-bugs@freefall.cdrom.com, netbsd-bugs@sun-lamp.cs.berkeley.edu>
From: Mark Treacy <mark@labtam.oz.au>
List: netbsd-bugs
Date: 10/05/1994 22:02:27
(Appologies for screwing up the To: address in my last mail)
This affects programs using SIOCGIFCONF, people seem to notice it first
with gated if they have a lot of ppp interfaces. I've seen the bug reported
numerous times, although I don't recall anyone posting a patch for the bug.
Here's one, (btw, workbuf is twice as large as it need be)
*** /home4/NetBSD/NetBSD-current/src/sys/net/if.c Sun Aug 14 21:02:16 1994
--- usr/src/sys/net/if.c Wed Oct 5 18:49:22 1994
***************
*** 587,596 ****
ifrp = ifc->ifc_req;
ep = ifr.ifr_name + sizeof (ifr.ifr_name) - 2;
for (; space > sizeof (ifr) && ifp; ifp = ifp->if_next) {
! strncpy(ifr.ifr_name, ifp->if_name, sizeof(ifr.ifr_name) - 2);
for (cp = ifr.ifr_name; cp < ep && *cp; cp++)
continue;
! *cp++ = '0' + ifp->if_unit; *cp = '\0';
if ((ifa = ifp->if_addrlist) == 0) {
bzero((caddr_t)&ifr.ifr_addr, sizeof(ifr.ifr_addr));
error = copyout((caddr_t)&ifr, (caddr_t)ifrp,
--- 587,602 ----
ifrp = ifc->ifc_req;
ep = ifr.ifr_name + sizeof (ifr.ifr_name) - 2;
for (; space > sizeof (ifr) && ifp; ifp = ifp->if_next) {
! char workbuf[12], *unitname;
! int unitlen;
!
! unitname = sprint_d(ifp->if_unit, workbuf, sizeof(workbuf));
! unitlen = strlen(unitname);
! strncpy(ifr.ifr_name, ifp->if_name,
! sizeof(ifr.ifr_name) - (unitlen+1));
for (cp = ifr.ifr_name; cp < ep && *cp; cp++)
continue;
! strcpy(cp, unitname);
if ((ifa = ifp->if_addrlist) == 0) {
bzero((caddr_t)&ifr.ifr_addr, sizeof(ifr.ifr_addr));
error = copyout((caddr_t)&ifr, (caddr_t)ifrp,