mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-09-03 15:56:00 +00:00
- Reference expression lists as we walk them, just in case they
get dereferenced.
This commit is contained in:
@@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"$Id: execute.c,v 1.34 2000/07/06 10:04:03 mellon Exp $ Copyright (c) 1998-2000 The Internet Software Consortium. All rights reserved.\n";
|
"$Id: execute.c,v 1.35 2000/07/06 22:42:22 mellon Exp $ Copyright (c) 1998-2000 The Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@@ -58,7 +58,7 @@ int execute_statements (packet, lease, in_options, out_options, scope,
|
|||||||
struct binding_scope *scope;
|
struct binding_scope *scope;
|
||||||
struct executable_statement *statements;
|
struct executable_statement *statements;
|
||||||
{
|
{
|
||||||
struct executable_statement *r, *e;
|
struct executable_statement *r, *e, *next;
|
||||||
int result;
|
int result;
|
||||||
int status;
|
int status;
|
||||||
unsigned long num;
|
unsigned long num;
|
||||||
@@ -70,7 +70,13 @@ int execute_statements (packet, lease, in_options, out_options, scope,
|
|||||||
if (!statements)
|
if (!statements)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (r = statements; r; r = r -> next) {
|
r = (struct executable_statement *)0;
|
||||||
|
next = (struct executable_statement *)0;
|
||||||
|
e = (struct executable_statement *)0;
|
||||||
|
executable_statement_reference (&r, statements, MDL);
|
||||||
|
while (r) {
|
||||||
|
if (r -> next)
|
||||||
|
executable_statement_reference (&next, r -> next, MDL);
|
||||||
switch (r -> op) {
|
switch (r -> op) {
|
||||||
case statements_statement:
|
case statements_statement:
|
||||||
#if defined (DEBUG_EXPRESSIONS)
|
#if defined (DEBUG_EXPRESSIONS)
|
||||||
@@ -131,17 +137,24 @@ int execute_statements (packet, lease, in_options, out_options, scope,
|
|||||||
#if defined (DEBUG_EXPRESSIONS)
|
#if defined (DEBUG_EXPRESSIONS)
|
||||||
log_debug ("exec: switch");
|
log_debug ("exec: switch");
|
||||||
#endif
|
#endif
|
||||||
e = find_matching_case (packet, lease,
|
status = (find_matching_case
|
||||||
|
(&e, packet, lease,
|
||||||
in_options, out_options, scope,
|
in_options, out_options, scope,
|
||||||
r -> data.s_switch.expr,
|
r -> data.s_switch.expr,
|
||||||
r -> data.s_switch.statements);
|
r -> data.s_switch.statements));
|
||||||
#if defined (DEBUG_EXPRESSIONS)
|
#if defined (DEBUG_EXPRESSIONS)
|
||||||
log_debug ("exec: switch: case %lx", (unsigned long)e);
|
log_debug ("exec: switch: case %lx", (unsigned long)e);
|
||||||
#endif
|
#endif
|
||||||
if (e && !execute_statements (packet, lease,
|
if (status) {
|
||||||
in_options, out_options,
|
if (!(execute_statements
|
||||||
scope, e))
|
(packet, lease,
|
||||||
|
in_options, out_options, scope, e))) {
|
||||||
|
executable_statement_dereference
|
||||||
|
(&e, MDL);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
executable_statement_dereference (&e, MDL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* These have no effect when executed. */
|
/* These have no effect when executed. */
|
||||||
@@ -356,6 +369,11 @@ int execute_statements (packet, lease, in_options, out_options, scope,
|
|||||||
default:
|
default:
|
||||||
log_fatal ("bogus statement type %d", r -> op);
|
log_fatal ("bogus statement type %d", r -> op);
|
||||||
}
|
}
|
||||||
|
executable_statement_dereference (&r, MDL);
|
||||||
|
if (next) {
|
||||||
|
executable_statement_reference (&r, next, MDL);
|
||||||
|
executable_statement_dereference (&next, MDL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -749,16 +767,13 @@ void write_statements (file, statements, indent)
|
|||||||
return that (the default statement can precede all the case statements).
|
return that (the default statement can precede all the case statements).
|
||||||
Otherwise, return the null statement. */
|
Otherwise, return the null statement. */
|
||||||
|
|
||||||
struct executable_statement *find_matching_case (packet, lease, in_options,
|
int find_matching_case (struct executable_statement **ep,
|
||||||
out_options, scope,
|
struct packet *packet, struct lease *lease,
|
||||||
expr, stmt)
|
struct option_state *in_options,
|
||||||
struct packet *packet;
|
struct option_state *out_options,
|
||||||
struct lease *lease;
|
struct binding_scope *scope,
|
||||||
struct option_state *in_options;
|
struct expression *expr,
|
||||||
struct option_state *out_options;
|
struct executable_statement *stmt)
|
||||||
struct binding_scope *scope;
|
|
||||||
struct expression *expr;
|
|
||||||
struct executable_statement *stmt;
|
|
||||||
{
|
{
|
||||||
int status, sub;
|
int status, sub;
|
||||||
struct executable_statement *s;
|
struct executable_statement *s;
|
||||||
@@ -784,7 +799,9 @@ struct executable_statement *find_matching_case (packet, lease, in_options,
|
|||||||
{
|
{
|
||||||
data_string_forget (&cd, MDL);
|
data_string_forget (&cd, MDL);
|
||||||
data_string_forget (&ds, MDL);
|
data_string_forget (&ds, MDL);
|
||||||
return s -> next;
|
executable_statement_reference
|
||||||
|
(ep, s -> next, MDL);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
data_string_forget (&cd, MDL);
|
data_string_forget (&cd, MDL);
|
||||||
}
|
}
|
||||||
@@ -803,8 +820,11 @@ struct executable_statement *find_matching_case (packet, lease, in_options,
|
|||||||
sub = (evaluate_numeric_expression
|
sub = (evaluate_numeric_expression
|
||||||
(&c, packet, lease, in_options,
|
(&c, packet, lease, in_options,
|
||||||
out_options, scope, s -> data.c_case));
|
out_options, scope, s -> data.c_case));
|
||||||
if (sub && n == c)
|
if (sub && n == c) {
|
||||||
return s -> next;
|
executable_statement_reference
|
||||||
|
(ep, s -> next, MDL);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -815,7 +835,9 @@ struct executable_statement *find_matching_case (packet, lease, in_options,
|
|||||||
for (s = stmt; s; s = s -> next)
|
for (s = stmt; s; s = s -> next)
|
||||||
if (s -> op == default_statement)
|
if (s -> op == default_statement)
|
||||||
break;
|
break;
|
||||||
if (s)
|
if (s) {
|
||||||
return s -> next;
|
executable_statement_reference (ep, s -> next, MDL);
|
||||||
return (struct executable_statement *)0;
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user