diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2012-11-25 16:45:32 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2012-11-25 16:45:32 +0000 |
commit | fd672504b20e033fde3663abc4c6567a23a902f5 (patch) | |
tree | 5720362603edeb9fddc3894165bf7b75e5355329 /sbin | |
parent | 4519057d8d103717a65852648127ea04a98db5bd (diff) |
Clean up parsing of option lists. Part 3.
Storing an option in a list more than once is silly, wastes space
and is possibly confusing to sensitive dhcp servers. Make it a
syntax error to attempt to store an option in a list more than once.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dhclient/clparse.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index 305f2ffb259..197871e8006 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clparse.c,v 1.45 2012/11/25 14:56:55 krw Exp $ */ +/* $OpenBSD: clparse.c,v 1.46 2012/11/25 16:45:31 krw Exp $ */ /* Parser for dhclient config and lease files... */ @@ -299,7 +299,7 @@ parse_X(FILE *cfile, u_int8_t *buf, int max) int parse_option_list(FILE *cfile, u_int8_t *list, size_t sz) { - int ix, i; + int ix, i, j; int token; char *val; @@ -331,6 +331,15 @@ parse_option_list(FILE *cfile, u_int8_t *list, size_t sz) skip_to_semi(cfile); return (0); } + /* Avoid storing duplicate options in the list. */ + for (j = 0; j < ix; j++) { + if (list[j] == i) { + parse_warn("%s: option in list more than once.", + val); + skip_to_semi(cfile); + return (0); + } + } list[ix++] = i; token = next_token(&val, cfile); } while (token == ','); |