summaryrefslogtreecommitdiff
path: root/common/parse.c
diff options
context:
space:
mode:
authorShawn Routhier <sar@isc.org>2012-06-06 22:50:31 +0000
committerShawn Routhier <sar@isc.org>2012-06-06 22:50:31 +0000
commit35de6c8c24b53adab2e69456373aecbecbe54a95 (patch)
tree7633b53eb69ec0cbbbd084782a65d1f77f9fd7de /common/parse.c
parent9f9265b63f0216176aada825a7152ef5ded64a1e (diff)
downloadisc-dhcp-35de6c8c24b53adab2e69456373aecbecbe54a95.tar.gz
Fix some issues in the code for parsing and printing options.
[ISC-Bugs #22625] - properly print options that have several fields followed by an array of something for example "fIa" [ISC-Bugs #27289] - properly parse options in declarations that have several fields followed by an array of something for example "fIa" [ISC-Bugs #27296] - properly determine if we parsed a 16 or 32 bit value in evaluate_numeric_expression (extract-int). [ISC-Bugs #27314] - properly parse a zero length option from a lease file. Thanks to Marius Tomaschewski from SUSE for the report and prototype patch for this ticket as well as ticket 27289.
Diffstat (limited to 'common/parse.c')
-rw-r--r--common/parse.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/common/parse.c b/common/parse.c
index 434085a2..f72c0d65 100644
--- a/common/parse.c
+++ b/common/parse.c
@@ -5518,11 +5518,26 @@ int parse_option_decl (oc, cfile)
if (status != ISC_R_SUCCESS || option == NULL)
return 0;
+ fmt = option->format;
+
/* Parse the option data... */
do {
- for (fmt = option -> format; *fmt; fmt++) {
- if (*fmt == 'A')
+ for (; *fmt; fmt++) {
+ if (*fmt == 'A') {
+ /* 'A' is an array of records, start at
+ * the beginning
+ */
+ fmt = option->format;
+ break;
+ }
+
+ if (*fmt == 'a') {
+ /* 'a' is an array of the last field,
+ * back up one format character
+ */
+ fmt--;
break;
+ }
if (*fmt == 'o' && fmt != option -> format)
continue;
switch (*fmt) {
@@ -5718,7 +5733,7 @@ int parse_option_decl (oc, cfile)
goto alloc;
case 'Z': /* Zero-length option */
- token = next_token(&val, (unsigned *)0, cfile);
+ token = peek_token(&val, (unsigned *)0, cfile);
if (token != SEMI) {
parse_warn(cfile,
"semicolon expected.");
@@ -5735,7 +5750,7 @@ int parse_option_decl (oc, cfile)
}
}
token = next_token (&val, (unsigned *)0, cfile);
- } while (*fmt == 'A' && token == COMMA);
+ } while (*fmt && token == COMMA);
if (token != SEMI) {
parse_warn (cfile, "semicolon expected.");