diff options
author | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2004-02-28 09:14:11 +0000 |
---|---|---|
committer | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2004-02-28 09:14:11 +0000 |
commit | a205a6786db5fb392350a3e87291aa7bdde3fe90 (patch) | |
tree | 434a5083fd705c41d100ece375fb755ee5d9e9d4 /sys/net/if.c | |
parent | daf28bb440e812ec8e982dc8405151d33e4a2390 (diff) |
- Don't permit 0-padded unit numbers on cloned interfaces. Bug repoprt
from otto@
- Fix signedness issue with unit numbers. Bug report from Thorsten Glaser
ok millert@ otto@
Diffstat (limited to 'sys/net/if.c')
-rw-r--r-- | sys/net/if.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index c6178ab3223..0a0620fa711 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.83 2004/02/08 19:46:10 markus Exp $ */ +/* $OpenBSD: if.c,v 1.84 2004/02/28 09:14:10 mcbride Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -694,6 +694,9 @@ if_clone_lookup(name, unitp) if (cp == name || cp - name == IFNAMSIZ || !*cp) return (NULL); /* No name or unit number */ + if (cp - name < IFNAMSIZ-1 && *cp == '0' && cp[1] != '\0') + return (NULL); /* unit number 0 padded */ + LIST_FOREACH(ifc, &if_cloners, ifc_list) { if (strlen(ifc->ifc_name) == cp - name && !strncmp(name, ifc->ifc_name, cp - name)) @@ -705,7 +708,8 @@ if_clone_lookup(name, unitp) unit = 0; while (cp - name < IFNAMSIZ && *cp) { - if (*cp < '0' || *cp > '9' || unit > INT_MAX / 10) { + if (*cp < '0' || *cp > '9' || + unit > (INT_MAX - (*cp - '0')) / 10) { /* Bogus unit number. */ return (NULL); } |