Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!brl-tgr!tgr!stanonik@nprdc.arpa From: stanonik@nprdc.arpa (Ron Stanonik) Newsgroups: net.unix-wizards Subject: colliding interface names Message-ID: <746@brl-tgr.ARPA> Date: Mon, 16-Dec-85 15:59:57 EST Article-I.D.: brl-tgr.746 Posted: Mon Dec 16 15:59:57 1985 Date-Received: Wed, 18-Dec-85 02:23:44 EST Sender: news@brl-tgr.ARPA Lines: 68 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;