summaryrefslogtreecommitdiff
path: root/common/parse.c
diff options
context:
space:
mode:
authorShawn Routhier <sar@isc.org>2010-12-29 22:56:01 +0000
committerShawn Routhier <sar@isc.org>2010-12-29 22:56:01 +0000
commite1a402115d2522187ef1706b4735cc00de5c3b28 (patch)
treed7f6503c8b7edfff415ddb789ac86152ea03af79 /common/parse.c
parent9043399dc37f81fae4c32f04442b2b1a5878cdcc (diff)
downloadisc-dhcp-e1a402115d2522187ef1706b4735cc00de5c3b28.tar.gz
When processing the format flags for a given option consume the
flag indicating an optional value correctly. A symptom of this bug was an infinite loop when trying to parse the slp-service-scope option. Thanks to a patch from Marius Tomaschewski. [ISC-Bugs #22055]
Diffstat (limited to 'common/parse.c')
-rw-r--r--common/parse.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/common/parse.c b/common/parse.c
index f459d239..40e95297 100644
--- a/common/parse.c
+++ b/common/parse.c
@@ -4977,8 +4977,28 @@ struct option *option;
do {
if ((*fmt == 'A') || (*fmt == 'a'))
break;
- if (*fmt == 'o')
+ if (*fmt == 'o') {
+ /* consume the optional flag */
+ fmt++;
continue;
+ }
+
+ if (fmt[1] == 'o') {
+ /*
+ * A value for the current format is
+ * optional - check to see if the next
+ * token is a semi-colon if so we don't
+ * need to parse it and doing so would
+ * consume the semi-colon which our
+ * caller is expecting to parse
+ */
+ token = peek_token(&val, (unsigned *)0,
+ cfile);
+ if (token == SEMI) {
+ fmt++;
+ continue;
+ }
+ }
tmp = *expr;
*expr = NULL;