2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-31 06:15:55 +00:00

- Make is_boolean_expression return true for expr_exists.

- Conditionalize pointer debug abort on POINTER_DEBUG.
- When using options in expression evaluation, make sure that there are
  options to use.
This commit is contained in:
Ted Lemon
1999-05-07 17:10:38 +00:00
parent b2e17924d1
commit 10da3e76fb

View File

@@ -22,7 +22,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: tree.c,v 1.27 1999/04/23 22:22:55 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; "$Id: tree.c,v 1.28 1999/05/07 17:10:38 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@@ -484,7 +484,8 @@ int evaluate_boolean_expression (result, packet, options, expr)
case expr_exists: case expr_exists:
memset (&left, 0, sizeof left); memset (&left, 0, sizeof left);
if (!((*expr -> data.option -> universe -> get_func) if (!options ||
!((*expr -> data.option -> universe -> get_func)
(&left, expr -> data.exists -> universe, (&left, expr -> data.exists -> universe,
options, expr -> data.exists -> code))) options, expr -> data.exists -> code)))
*result = 0; *result = 0;
@@ -632,9 +633,12 @@ int evaluate_data_expression (result, packet, options, expr)
/* Extract an option. */ /* Extract an option. */
case expr_option: case expr_option:
s0 = ((*expr -> data.option -> universe -> get_func) if (options)
(result, expr -> data.option -> universe, s0 = ((*expr -> data.option -> universe -> get_func)
options, expr -> data.option -> code)); (result, expr -> data.option -> universe,
options, expr -> data.option -> code));
else
s0 = 0;
#if defined (DEBUG_EXPRESSIONS) #if defined (DEBUG_EXPRESSIONS)
log_info ("data: option %s.%s = %s", log_info ("data: option %s.%s = %s",
@@ -658,7 +662,7 @@ int evaluate_data_expression (result, packet, options, expr)
} }
result -> len = packet -> raw -> hlen + 1; result -> len = packet -> raw -> hlen + 1;
if (buffer_allocate (&result -> buffer, result -> len, if (buffer_allocate (&result -> buffer, result -> len,
"evaluate_data_expression")) { "evaluate_data_expression")) {
result -> data = &result -> buffer -> data [0]; result -> data = &result -> buffer -> data [0];
result -> data [0] = packet -> raw -> htype; result -> data [0] = packet -> raw -> htype;
memcpy (&result -> data [1], packet -> raw -> chaddr, memcpy (&result -> data [1], packet -> raw -> chaddr,
@@ -699,7 +703,7 @@ int evaluate_data_expression (result, packet, options, expr)
+ offset), result -> len); + offset), result -> len);
result -> terminated = 0; result -> terminated = 0;
} else { } else {
log_error ("data: packet: no memory for buffer."); log_error ("data: packet: no buffer memory.");
return 0; return 0;
} }
s2 = 1; s2 = 1;
@@ -716,8 +720,12 @@ int evaluate_data_expression (result, packet, options, expr)
/* The encapsulation of all defined options in an /* The encapsulation of all defined options in an
option space... */ option space... */
case expr_encapsulate: case expr_encapsulate:
s0 = option_space_encapsulate (result, options, if (options)
&expr -> data.encapsulate); s0 = option_space_encapsulate
(result, options, &expr -> data.encapsulate);
else
s0 = 0;
#if defined (DEBUG_EXPRESSIONS) #if defined (DEBUG_EXPRESSIONS)
log_info ("data: encapsulate (%s) = %s", log_info ("data: encapsulate (%s) = %s",
expr -> data.encapsulate.data, expr -> data.encapsulate.data,
@@ -902,7 +910,7 @@ int evaluate_numeric_expression (result, packet, options, expr)
return 1; return 1;
} }
log_error ("Bogus opcode in evaluate_numeric_expression: %d", expr -> op); log_error ("evaluate_numeric_expression: bogus opcode %d", expr -> op);
return 0; return 0;
} }
@@ -940,7 +948,7 @@ int evaluate_boolean_option_cache (packet, options, oc)
int result; int result;
/* So that we can be called with option_lookup as an argument. */ /* So that we can be called with option_lookup as an argument. */
if (!oc) if (!oc || !options)
return 0; return 0;
memset (&ds, 0, sizeof ds); memset (&ds, 0, sizeof ds);
@@ -994,7 +1002,11 @@ void expression_dereference (eptr, name)
return; return;
if (expr -> refcnt < 0) { if (expr -> refcnt < 0) {
log_error ("expression_dereference: negative refcnt!"); log_error ("expression_dereference: negative refcnt!");
#if defined (POINTER_DEBUG)
abort (); abort ();
#else
return;
#endif
} }
/* Dereference subexpressions. */ /* Dereference subexpressions. */
@@ -1124,6 +1136,7 @@ int is_boolean_expression (expr)
struct expression *expr; struct expression *expr;
{ {
return (expr -> op == expr_check || return (expr -> op == expr_check ||
expr -> op == expr_exists ||
expr -> op == expr_equal || expr -> op == expr_equal ||
expr -> op == expr_and || expr -> op == expr_and ||
expr -> op == expr_or || expr -> op == expr_or ||