Use stricter checking to match possible vlan clones by not allowing extra

garbage characters around or within the tag.

Reviewed by:	brooks
MFC after:	3 days
This commit is contained in:
John Baldwin 2009-12-31 20:44:38 +00:00
parent a6fffd6cb0
commit fb92ad4af5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=201351

View File

@ -582,7 +582,7 @@ vlan_clone_match_ethertag(struct if_clone *ifc, const char *name, int *tag)
{
const char *cp;
struct ifnet *ifp;
int t = 0;
int t;
/* Check for <etherif>.<vlan> style interface names. */
IFNET_RLOCK_NOSLEEP();
@ -592,13 +592,15 @@ vlan_clone_match_ethertag(struct if_clone *ifc, const char *name, int *tag)
if (strncmp(ifp->if_xname, name, strlen(ifp->if_xname)) != 0)
continue;
cp = name + strlen(ifp->if_xname);
if (*cp != '.')
if (*cp++ != '.')
continue;
for(; *cp != '\0'; cp++) {
if (*cp < '0' || *cp > '9')
continue;
if (*cp == '\0')
continue;
t = 0;
for(; *cp >= '0' && *cp <= '9'; cp++)
t = (t * 10) + (*cp - '0');
}
if (*cp != '\0')
continue;
if (tag != NULL)
*tag = t;
break;