summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2012-11-25 16:45:32 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2012-11-25 16:45:32 +0000
commitfd672504b20e033fde3663abc4c6567a23a902f5 (patch)
tree5720362603edeb9fddc3894165bf7b75e5355329 /sbin
parent4519057d8d103717a65852648127ea04a98db5bd (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.c13
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 == ',');