diff options
author | jhb <jhb@FreeBSD.org> | 2009-12-31 20:44:38 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2009-12-31 20:44:38 +0000 |
commit | 26cb0488b332d118bee05b0cbef1c41922b76615 (patch) | |
tree | 60f7f94bcc53271ce3a5a2dd9c3b0920aa22db48 /sys/net | |
parent | a5cc24440bfbf4dc6eeb27b3770d09132b85bd31 (diff) | |
download | FreeBSD-src-26cb0488b332d118bee05b0cbef1c41922b76615.zip FreeBSD-src-26cb0488b332d118bee05b0cbef1c41922b76615.tar.gz |
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
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if_vlan.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 1fd70d5..6a85956 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -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; |