stanonik@nprdc.arpa (Ron Stanonik) (12/16/85)
Description: Ioctl's can affect the wrong interface if you have interfaces with similar names; eg, sl and slip. The problem is that ifunit(name), in sys/net/if.c, bcmp's its argument to each interface name, but doesn't compare lengths. So, sl, being a prefix of slip, matches. (I feel as though I've seen a fix for this, but couldn't find it.) By the way, 4.3BSD seems to have the same bug. Repeat-By: We have two serial interfaces, "sl" from rick@seismo.arpa, and "slip" from ks@purdue-ecn.arpa. The "slip" interface was if_attach'ed first. Ifconfig'ing "sl" clobbered the "slip" interface. Fix: --- if.c Mon Dec 16 12:04:59 1985 *************** *** 184,190 { register char *cp; register struct ifnet *ifp; ! int unit; for (cp = name; cp < name + IFNAMSIZ && *cp; cp++) if (*cp >= '0' && *cp <= '9') --- 184,190 ----- { register char *cp; register struct ifnet *ifp; ! int unit, len; for (cp = name; cp < name + IFNAMSIZ && *cp; cp++) if (*cp >= '0' && *cp <= '9') *************** *** 192,197 if (*cp == '\0' || cp == name + IFNAMSIZ) return ((struct ifnet *)0); unit = *cp - '0', *cp = 0; for (ifp = ifnet; ifp; ifp = ifp->if_next) { if (bcmp(ifp->if_name, name, (unsigned)(cp - name))) continue; --- 192,198 ----- if (*cp == '\0' || cp == name + IFNAMSIZ) return ((struct ifnet *)0); unit = *cp - '0', *cp = 0; + len = (int)(cp - name); for (ifp = ifnet; ifp; ifp = ifp->if_next) { if (strlen(ifp->if_name) != len || bcmp(ifp->if_name, name, len)) continue; *************** *** 193,199 return ((struct ifnet *)0); unit = *cp - '0', *cp = 0; for (ifp = ifnet; ifp; ifp = ifp->if_next) { ! if (bcmp(ifp->if_name, name, (unsigned)(cp - name))) continue; if (unit == ifp->if_unit) break; --- 194,200 ----- unit = *cp - '0', *cp = 0; len = (int)(cp - name); for (ifp = ifnet; ifp; ifp = ifp->if_next) { ! if (strlen(ifp->if_name) != len || bcmp(ifp->if_name, name, len)) continue; if (unit == ifp->if_unit) break;