summaryrefslogtreecommitdiff
path: root/common/tree.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/tree.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/tree.c')
-rw-r--r--common/tree.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/common/tree.c b/common/tree.c
index 3c978b09..c82ac271 100644
--- a/common/tree.c
+++ b/common/tree.c
@@ -3,7 +3,7 @@
Routines for manipulating parse trees... */
/*
- * Copyright (c) 2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2011-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2007,2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
@@ -2409,6 +2409,7 @@ int evaluate_numeric_expression (result, packet, lease, client_state,
struct binding *binding;
struct binding_value *bv;
unsigned long ileft, iright;
+ int rc = 0;
switch (expr -> op) {
case expr_check:
@@ -2477,32 +2478,42 @@ int evaluate_numeric_expression (result, packet, lease, client_state,
status = (evaluate_data_expression
(&data, packet, lease, client_state, in_options,
cfg_options, scope, expr -> data.extract_int, MDL));
- if (status && data.len >= 2)
+ if (status && data.len >= 2) {
*result = getUShort (data.data);
+ rc = 1;
+ }
#if defined (DEBUG_EXPRESSIONS)
- log_debug ("num: extract_int16 (%s) = %ld",
- ((status && data.len >= 2) ?
- print_hex_1 (data.len, data.data, 60) : "NULL"),
- *result);
+ if (rc == 1) {
+ log_debug ("num: extract_int16 (%s) = %ld",
+ print_hex_1(data.len, data.data, 60)
+ *result);
+ } else {
+ log_debug ("num: extract_int16 (NULL) = NULL");
+ }
#endif
if (status) data_string_forget (&data, MDL);
- return (status && data.len >= 2);
+ return (rc);
case expr_extract_int32:
memset (&data, 0, sizeof data);
status = (evaluate_data_expression
(&data, packet, lease, client_state, in_options,
cfg_options, scope, expr -> data.extract_int, MDL));
- if (status && data.len >= 4)
+ if (status && data.len >= 4) {
*result = getULong (data.data);
+ rc = 1;
+ }
#if defined (DEBUG_EXPRESSIONS)
- log_debug ("num: extract_int32 (%s) = %ld",
- ((status && data.len >= 4) ?
- print_hex_1 (data.len, data.data, 60) : "NULL"),
- *result);
+ if (rc == 1) {
+ log_debug ("num: extract_int32 (%s) = %ld",
+ print_hex_1 (data.len, data.data, 60),
+ *result);
+ } else {
+ log_debug ("num: extract_int32 (NULL) = NULL");
+ }
#endif
if (status) data_string_forget (&data, MDL);
- return (status && data.len >= 4);
+ return (rc);
case expr_const_int:
*result = expr -> data.const_int;