2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-31 14:25:41 +00:00

Support NUL characters in STRING tokens.

This commit is contained in:
Ted Lemon
2001-03-17 00:47:39 +00:00
parent 5a3adf94a7
commit b3519f23f1
7 changed files with 585 additions and 526 deletions

View File

@@ -43,7 +43,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: clparse.c,v 1.57 2001/03/01 18:16:57 mellon Exp $ Copyright (c) 1996-2001 The Internet Software Consortium. All rights reserved.\n"; "$Id: clparse.c,v 1.58 2001/03/17 00:47:30 mellon Exp $ Copyright (c) 1996-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@@ -113,14 +113,14 @@ isc_result_t read_client_conf ()
new_parse (&cfile, file, (char *)0, 0, path_dhclient_conf); new_parse (&cfile, file, (char *)0, 0, path_dhclient_conf);
do { do {
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == END_OF_FILE) if (token == END_OF_FILE)
break; break;
parse_client_statement (cfile, parse_client_statement (cfile,
(struct interface_info *)0, (struct interface_info *)0,
&top_level_config); &top_level_config);
} while (1); } while (1);
token = next_token (&val, cfile); /* Clear the peek buffer */ token = next_token (&val, (unsigned *)0, cfile); /* Clear the peek buffer */
status = (cfile -> warnings_occurred status = (cfile -> warnings_occurred
? ISC_R_BADPARSE ? ISC_R_BADPARSE
: ISC_R_SUCCESS); : ISC_R_SUCCESS);
@@ -176,7 +176,7 @@ void read_client_leases ()
new_parse (&cfile, file, (char *)0, 0, path_dhclient_db); new_parse (&cfile, file, (char *)0, 0, path_dhclient_db);
do { do {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token == END_OF_FILE) if (token == END_OF_FILE)
break; break;
if (token != LEASE) { if (token != LEASE) {
@@ -229,9 +229,9 @@ void parse_client_statement (cfile, ip, config)
int known; int known;
int tmp, i; int tmp, i;
switch (peek_token (&val, cfile)) { switch (peek_token (&val, (unsigned *)0, cfile)) {
case KEY: case KEY:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
if (ip) { if (ip) {
/* This may seem arbitrary, but there's a reason for /* This may seem arbitrary, but there's a reason for
doing it: the authentication key database is not doing it: the authentication key database is not
@@ -255,8 +255,8 @@ void parse_client_statement (cfile, ip, config)
/* REQUIRE can either start a policy statement or a /* REQUIRE can either start a policy statement or a
comma-seperated list of names of required options. */ comma-seperated list of names of required options. */
case REQUIRE: case REQUIRE:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == AUTHENTICATION) { if (token == AUTHENTICATION) {
policy = P_REQUIRE; policy = P_REQUIRE;
goto do_policy; goto do_policy;
@@ -265,27 +265,27 @@ void parse_client_statement (cfile, ip, config)
return; return;
case IGNORE: case IGNORE:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
policy = P_IGNORE; policy = P_IGNORE;
goto do_policy; goto do_policy;
case ACCEPT: case ACCEPT:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
policy = P_ACCEPT; policy = P_ACCEPT;
goto do_policy; goto do_policy;
case PREFER: case PREFER:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
policy = P_PREFER; policy = P_PREFER;
goto do_policy; goto do_policy;
case DONT: case DONT:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
policy = P_DONT; policy = P_DONT;
goto do_policy; goto do_policy;
do_policy: do_policy:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token == AUTHENTICATION) { if (token == AUTHENTICATION) {
if (policy != P_PREFER && if (policy != P_PREFER &&
policy != P_REQUIRE && policy != P_REQUIRE &&
@@ -313,9 +313,9 @@ void parse_client_statement (cfile, ip, config)
break; break;
case OPTION: case OPTION:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == SPACE) { if (token == SPACE) {
if (ip) { if (ip) {
parse_warn (cfile, parse_warn (cfile,
@@ -332,7 +332,7 @@ void parse_client_statement (cfile, ip, config)
if (!option) if (!option)
return; return;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != CODE) { if (token != CODE) {
parse_warn (cfile, "expecting \"code\" keyword."); parse_warn (cfile, "expecting \"code\" keyword.");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -352,12 +352,12 @@ void parse_client_statement (cfile, ip, config)
return; return;
case MEDIA: case MEDIA:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
parse_string_list (cfile, &config -> media, 1); parse_string_list (cfile, &config -> media, 1);
return; return;
case HARDWARE: case HARDWARE:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (ip) { if (ip) {
parse_hardware_param (cfile, &ip -> hw_address); parse_hardware_param (cfile, &ip -> hw_address);
} else { } else {
@@ -368,36 +368,36 @@ void parse_client_statement (cfile, ip, config)
return; return;
case REQUEST: case REQUEST:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (config -> requested_options == default_requested_options) if (config -> requested_options == default_requested_options)
config -> requested_options = (u_int32_t *)0; config -> requested_options = (u_int32_t *)0;
parse_option_list (cfile, &config -> requested_options); parse_option_list (cfile, &config -> requested_options);
return; return;
case TIMEOUT: case TIMEOUT:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
parse_lease_time (cfile, &config -> timeout); parse_lease_time (cfile, &config -> timeout);
return; return;
case RETRY: case RETRY:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
parse_lease_time (cfile, &config -> retry_interval); parse_lease_time (cfile, &config -> retry_interval);
return; return;
case SELECT_TIMEOUT: case SELECT_TIMEOUT:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
parse_lease_time (cfile, &config -> select_interval); parse_lease_time (cfile, &config -> select_interval);
return; return;
case OMAPI: case OMAPI:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != PORT) { if (token != PORT) {
parse_warn (cfile, parse_warn (cfile,
"unexpected omapi subtype: %s", val); "unexpected omapi subtype: %s", val);
skip_to_semi (cfile); skip_to_semi (cfile);
return; return;
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != NUMBER) { if (token != NUMBER) {
parse_warn (cfile, "invalid port number: `%s'", val); parse_warn (cfile, "invalid port number: `%s'", val);
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -415,40 +415,40 @@ void parse_client_statement (cfile, ip, config)
return; return;
case REBOOT: case REBOOT:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
parse_lease_time (cfile, &config -> reboot_timeout); parse_lease_time (cfile, &config -> reboot_timeout);
return; return;
case BACKOFF_CUTOFF: case BACKOFF_CUTOFF:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
parse_lease_time (cfile, &config -> backoff_cutoff); parse_lease_time (cfile, &config -> backoff_cutoff);
return; return;
case INITIAL_INTERVAL: case INITIAL_INTERVAL:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
parse_lease_time (cfile, &config -> initial_interval); parse_lease_time (cfile, &config -> initial_interval);
return; return;
case SCRIPT: case SCRIPT:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
config -> script_name = parse_string (cfile); parse_string (cfile, &config -> script_name, (unsigned *)0);
return; return;
case VENDOR: case VENDOR:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != OPTION) { if (token != OPTION) {
parse_warn (cfile, "expecting 'vendor option space'"); parse_warn (cfile, "expecting 'vendor option space'");
skip_to_semi (cfile); skip_to_semi (cfile);
return; return;
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != SPACE) { if (token != SPACE) {
parse_warn (cfile, "expecting 'vendor option space'"); parse_warn (cfile, "expecting 'vendor option space'");
skip_to_semi (cfile); skip_to_semi (cfile);
return; return;
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (!is_identifier (token)) { if (!is_identifier (token)) {
parse_warn (cfile, "expecting an identifier."); parse_warn (cfile, "expecting an identifier.");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -470,15 +470,15 @@ void parse_client_statement (cfile, ip, config)
return; return;
case INTERFACE: case INTERFACE:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (ip) if (ip)
parse_warn (cfile, "nested interface declaration."); parse_warn (cfile, "nested interface declaration.");
parse_interface_declaration (cfile, config, (char *)0); parse_interface_declaration (cfile, config, (char *)0);
return; return;
case PSEUDO: case PSEUDO:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
name = dmalloc (strlen (val) + 1, MDL); name = dmalloc (strlen (val) + 1, MDL);
if (!name) if (!name)
log_fatal ("no memory for pseudo interface name"); log_fatal ("no memory for pseudo interface name");
@@ -487,17 +487,17 @@ void parse_client_statement (cfile, ip, config)
return; return;
case LEASE: case LEASE:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
parse_client_lease_statement (cfile, 1); parse_client_lease_statement (cfile, 1);
return; return;
case ALIAS: case ALIAS:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
parse_client_lease_statement (cfile, 2); parse_client_lease_statement (cfile, 2);
return; return;
case REJECT: case REJECT:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
parse_reject_statement (cfile, config); parse_reject_statement (cfile, config);
return; return;
@@ -556,7 +556,7 @@ void parse_option_list (cfile, list)
ix = 0; ix = 0;
do { do {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token == SEMI) if (token == SEMI)
break; break;
if (!is_identifier (token)) { if (!is_identifier (token)) {
@@ -584,7 +584,7 @@ void parse_option_list (cfile, list)
p = r; p = r;
q = r; q = r;
++ix; ++ix;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
} while (token == COMMA); } while (token == COMMA);
if (token != SEMI) { if (token != SEMI) {
parse_warn (cfile, "expecting semicolon."); parse_warn (cfile, "expecting semicolon.");
@@ -625,7 +625,7 @@ void parse_interface_declaration (cfile, outer_config, name)
struct client_state *client, **cp; struct client_state *client, **cp;
struct interface_info *ip = (struct interface_info *)0; struct interface_info *ip = (struct interface_info *)0;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != STRING) { if (token != STRING) {
parse_warn (cfile, "expecting interface name (in quotes)."); parse_warn (cfile, "expecting interface name (in quotes).");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -657,7 +657,7 @@ void parse_interface_declaration (cfile, outer_config, name)
ip -> flags &= ~INTERFACE_AUTOMATIC; ip -> flags &= ~INTERFACE_AUTOMATIC;
interfaces_requested = 1; interfaces_requested = 1;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != LBRACE) { if (token != LBRACE) {
parse_warn (cfile, "expecting left brace."); parse_warn (cfile, "expecting left brace.");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -665,7 +665,7 @@ void parse_interface_declaration (cfile, outer_config, name)
} }
do { do {
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == END_OF_FILE) { if (token == END_OF_FILE) {
parse_warn (cfile, parse_warn (cfile,
"unterminated interface declaration."); "unterminated interface declaration.");
@@ -675,7 +675,7 @@ void parse_interface_declaration (cfile, outer_config, name)
break; break;
parse_client_statement (cfile, ip, client -> config); parse_client_statement (cfile, ip, client -> config);
} while (1); } while (1);
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
} }
int interface_or_dummy (struct interface_info **pi, const char *name) int interface_or_dummy (struct interface_info **pi, const char *name)
@@ -770,7 +770,7 @@ void parse_client_lease_statement (cfile, is_static)
const char *val; const char *val;
struct client_state *client = (struct client_state *)0; struct client_state *client = (struct client_state *)0;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != LBRACE) { if (token != LBRACE) {
parse_warn (cfile, "expecting left brace."); parse_warn (cfile, "expecting left brace.");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -787,7 +787,7 @@ void parse_client_lease_statement (cfile, is_static)
log_fatal ("no memory for lease options.\n"); log_fatal ("no memory for lease options.\n");
do { do {
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == END_OF_FILE) { if (token == END_OF_FILE) {
parse_warn (cfile, "unterminated lease declaration."); parse_warn (cfile, "unterminated lease declaration.");
return; return;
@@ -796,7 +796,7 @@ void parse_client_lease_statement (cfile, is_static)
break; break;
parse_client_lease_declaration (cfile, lease, &ip, &client); parse_client_lease_declaration (cfile, lease, &ip, &client);
} while (1); } while (1);
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
/* If the lease declaration didn't include an interface /* If the lease declaration didn't include an interface
declaration that we recognized, it's of no use to us. */ declaration that we recognized, it's of no use to us. */
@@ -901,9 +901,9 @@ void parse_client_lease_declaration (cfile, lease, ipp, clientp)
struct client_state *client = (struct client_state *)0; struct client_state *client = (struct client_state *)0;
struct data_string key_id; struct data_string key_id;
switch (next_token (&val, cfile)) { switch (next_token (&val, (unsigned *)0, cfile)) {
case KEY: case KEY:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != STRING && !is_identifier (token)) { if (token != STRING && !is_identifier (token)) {
parse_warn (cfile, "expecting key name."); parse_warn (cfile, "expecting key name.");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -919,7 +919,7 @@ void parse_client_lease_declaration (cfile, lease, ipp, clientp)
break; break;
case INTERFACE: case INTERFACE:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != STRING) { if (token != STRING) {
parse_warn (cfile, parse_warn (cfile,
"expecting interface name (in quotes)."); "expecting interface name (in quotes).");
@@ -930,7 +930,7 @@ void parse_client_lease_declaration (cfile, lease, ipp, clientp)
break; break;
case NAME: case NAME:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
ip = *ipp; ip = *ipp;
if (!ip) { if (!ip) {
parse_warn (cfile, "state name precedes interface."); parse_warn (cfile, "state name precedes interface.");
@@ -955,11 +955,11 @@ void parse_client_lease_declaration (cfile, lease, ipp, clientp)
return; return;
case FILENAME: case FILENAME:
lease -> filename = parse_string (cfile); parse_string (cfile, &lease -> filename, (unsigned *)0);
return; return;
case SERVER_NAME: case SERVER_NAME:
lease -> server_name = parse_string (cfile); parse_string (cfile, &lease -> server_name, (unsigned *)0);
return; return;
case RENEW: case RENEW:
@@ -988,7 +988,7 @@ void parse_client_lease_declaration (cfile, lease, ipp, clientp)
skip_to_semi (cfile); skip_to_semi (cfile);
break; break;
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != SEMI) { if (token != SEMI) {
parse_warn (cfile, "expecting semicolon."); parse_warn (cfile, "expecting semicolon.");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -1013,7 +1013,7 @@ void parse_string_list (cfile, lp, multiple)
} }
do { do {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != STRING) { if (token != STRING) {
parse_warn (cfile, "Expecting media options."); parse_warn (cfile, "Expecting media options.");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -1036,7 +1036,7 @@ void parse_string_list (cfile, lp, multiple)
*lp = tmp; *lp = tmp;
cur = tmp; cur = tmp;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
} while (multiple && token == COMMA); } while (multiple && token == COMMA);
if (token != SEMI) { if (token != SEMI) {
@@ -1070,7 +1070,7 @@ void parse_reject_statement (cfile, config)
list -> next = config -> reject_list; list -> next = config -> reject_list;
config -> reject_list = list; config -> reject_list = list;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
} while (token == COMMA); } while (token == COMMA);
if (token != SEMI) { if (token != SEMI) {

View File

@@ -43,7 +43,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: conflex.c,v 1.89 2001/03/01 18:16:59 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n"; "$Id: conflex.c,v 1.90 2001/03/17 00:47:32 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@@ -210,6 +210,7 @@ static enum dhcp_token get_token (cfile)
break; break;
} else if (c == EOF) { } else if (c == EOF) {
ttok = END_OF_FILE; ttok = END_OF_FILE;
cfile -> tlen = 0;
break; break;
} else { } else {
cfile -> lexline = l; cfile -> lexline = l;
@@ -217,6 +218,7 @@ static enum dhcp_token get_token (cfile)
tb [0] = c; tb [0] = c;
tb [1] = 0; tb [1] = 0;
cfile -> tval = tb; cfile -> tval = tb;
cfile -> tlen = 1;
ttok = c; ttok = c;
break; break;
} }
@@ -224,8 +226,9 @@ static enum dhcp_token get_token (cfile)
return ttok; return ttok;
} }
enum dhcp_token next_token (rval, cfile) enum dhcp_token next_token (rval, rlen, cfile)
const char **rval; const char **rval;
unsigned *rlen;
struct parse *cfile; struct parse *cfile;
{ {
int rv; int rv;
@@ -243,14 +246,17 @@ enum dhcp_token next_token (rval, cfile)
} }
if (rval) if (rval)
*rval = cfile -> tval; *rval = cfile -> tval;
if (rlen)
*rlen = cfile -> tlen;
#ifdef DEBUG_TOKENS #ifdef DEBUG_TOKENS
fprintf (stderr, "%s:%d ", cfile -> tval, rv); fprintf (stderr, "%s:%d ", cfile -> tval, rv);
#endif #endif
return rv; return rv;
} }
enum dhcp_token peek_token (rval, cfile) enum dhcp_token peek_token (rval, rlen, cfile)
const char **rval; const char **rval;
unsigned int *rlen;
struct parse *cfile; struct parse *cfile;
{ {
int x; int x;
@@ -272,6 +278,8 @@ enum dhcp_token peek_token (rval, cfile)
} }
if (rval) if (rval)
*rval = cfile -> tval; *rval = cfile -> tval;
if (rlen)
*rlen = cfile -> tlen;
#ifdef DEBUG_TOKENS #ifdef DEBUG_TOKENS
fprintf (stderr, "(%s:%d) ", cfile -> tval, cfile -> token); fprintf (stderr, "(%s:%d) ", cfile -> tval, cfile -> token);
#endif #endif
@@ -400,6 +408,7 @@ static enum dhcp_token read_string (cfile)
--i; --i;
} }
cfile -> tokbuf [i] = 0; cfile -> tokbuf [i] = 0;
cfile -> tlen = i;
cfile -> tval = cfile -> tokbuf; cfile -> tval = cfile -> tokbuf;
return STRING; return STRING;
} }
@@ -437,6 +446,7 @@ static enum dhcp_token read_number (c, cfile)
--i; --i;
} }
cfile -> tokbuf [i] = 0; cfile -> tokbuf [i] = 0;
cfile -> tlen = i;
cfile -> tval = cfile -> tokbuf; cfile -> tval = cfile -> tokbuf;
return token; return token;
} }
@@ -465,6 +475,7 @@ static enum dhcp_token read_num_or_name (c, cfile)
--i; --i;
} }
cfile -> tokbuf [i] = 0; cfile -> tokbuf [i] = 0;
cfile -> tlen = i;
cfile -> tval = cfile -> tokbuf; cfile -> tval = cfile -> tokbuf;
return intern (cfile -> tval, rv); return intern (cfile -> tval, rv);
} }

File diff suppressed because it is too large Load Diff

View File

@@ -43,7 +43,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: resolv.c,v 1.14 2001/03/01 18:17:02 mellon Exp $ Copyright (c) 1996-2001 The Internet Software Consortium. All rights reserved.\n"; "$Id: resolv.c,v 1.15 2001/03/17 00:47:34 mellon Exp $ Copyright (c) 1996-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@@ -74,7 +74,7 @@ void read_resolv_conf (parse_time)
cfile -> eol_token = 1; cfile -> eol_token = 1;
do { do {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token == END_OF_FILE) if (token == END_OF_FILE)
break; break;
else if (token == EOL) else if (token == EOL)
@@ -106,14 +106,15 @@ void read_resolv_conf (parse_time)
dn = (char *)0; dn = (char *)0;
} }
nd -> rcdate = parse_time; nd -> rcdate = parse_time;
token = peek_token (&val, cfile); token = peek_token (&val,
(unsigned *)0, cfile);
} while (token != EOL); } while (token != EOL);
if (token != EOL) { if (token != EOL) {
parse_warn (cfile, parse_warn (cfile,
"junk after domain declaration"); "junk after domain declaration");
skip_to_semi (cfile); skip_to_semi (cfile);
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
} else if (token == NAMESERVER) { } else if (token == NAMESERVER) {
struct name_server *ns, **sp; struct name_server *ns, **sp;
struct iaddr iaddr; struct iaddr iaddr;
@@ -149,7 +150,7 @@ void read_resolv_conf (parse_time)
} else } else
skip_to_semi (cfile); /* Ignore what we don't grok. */ skip_to_semi (cfile); /* Ignore what we don't grok. */
} while (1); } while (1);
token = next_token (&val, cfile); /* Clear the peek buffer */ token = next_token (&val, (unsigned *)0, cfile);
/* Lose servers that are no longer in /etc/resolv.conf. */ /* Lose servers that are no longer in /etc/resolv.conf. */
sl = (struct name_server *)0; sl = (struct name_server *)0;

View File

@@ -218,7 +218,7 @@ int main (int argc, char **argv, char **envp)
status = new_parse (&cfile, 0, buf, strlen(buf), "<STDIN>"); status = new_parse (&cfile, 0, buf, strlen(buf), "<STDIN>");
check(status, "new_parse()"); check(status, "new_parse()");
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
switch (token) { switch (token) {
default: default:
parse_warn (cfile, "unknown token: %s", val); parse_warn (cfile, "unknown token: %s", val);
@@ -237,9 +237,10 @@ int main (int argc, char **argv, char **envp)
break; break;
case TOKEN_NEW: case TOKEN_NEW:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if ((!is_identifier (token) && token != STRING) || if ((!is_identifier (token) && token != STRING) ||
next_token (NULL, cfile) != END_OF_FILE) next_token (NULL,
(unsigned *)0, cfile) != END_OF_FILE)
{ {
printf ("usage: new <object-type>\n"); printf ("usage: new <object-type>\n");
break; break;
@@ -260,7 +261,8 @@ int main (int argc, char **argv, char **envp)
break; break;
case TOKEN_CLOSE: case TOKEN_CLOSE:
if (next_token (NULL, cfile) != END_OF_FILE) { if (next_token (NULL,
(unsigned *)0, cfile) != END_OF_FILE) {
printf ("usage: close\n"); printf ("usage: close\n");
} }
@@ -269,10 +271,10 @@ int main (int argc, char **argv, char **envp)
break; break;
case TOKEN_SET: case TOKEN_SET:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if ((!is_identifier (token) && token != STRING) || if ((!is_identifier (token) && token != STRING) ||
next_token (NULL, cfile) != '=') next_token (NULL, (unsigned *)0, cfile) != '=')
{ {
printf ("usage: set <name> = <value>\n"); printf ("usage: set <name> = <value>\n");
break; break;
@@ -286,7 +288,7 @@ int main (int argc, char **argv, char **envp)
s1[0] = '\0'; s1[0] = '\0';
strncat (s1, val, sizeof(s1)-1); strncat (s1, val, sizeof(s1)-1);
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
switch (token) { switch (token) {
case STRING: case STRING:
dhcpctl_set_string_value (oh, val, s1); dhcpctl_set_string_value (oh, val, s1);
@@ -304,7 +306,8 @@ int main (int argc, char **argv, char **envp)
case TOKEN_CREATE: case TOKEN_CREATE:
case TOKEN_OPEN: case TOKEN_OPEN:
if (next_token (NULL, cfile) != END_OF_FILE) { if (next_token (NULL,
(unsigned *)0, cfile) != END_OF_FILE) {
printf ("usage: %s\n", val); printf ("usage: %s\n", val);
} }
@@ -327,7 +330,8 @@ int main (int argc, char **argv, char **envp)
break; break;
case UPDATE: case UPDATE:
if (next_token (NULL, cfile) != END_OF_FILE) { if (next_token (NULL, (unsigned *)0,
cfile) != END_OF_FILE) {
printf ("usage: %s\n", val); printf ("usage: %s\n", val);
} }

View File

@@ -119,6 +119,7 @@ struct parse {
enum dhcp_token token; enum dhcp_token token;
int ugflag; int ugflag;
char *tval; char *tval;
int tlen;
char tokbuf [1500]; char tokbuf [1500];
#ifdef OLD_LEXER #ifdef OLD_LEXER
@@ -1081,8 +1082,8 @@ int dhcpd_interface_setup_hook (struct interface_info *ip, struct iaddr *ia);
isc_result_t new_parse PROTO ((struct parse **, int, isc_result_t new_parse PROTO ((struct parse **, int,
char *, unsigned, const char *)); char *, unsigned, const char *));
isc_result_t end_parse PROTO ((struct parse **)); isc_result_t end_parse PROTO ((struct parse **));
enum dhcp_token next_token PROTO ((const char **, struct parse *)); enum dhcp_token next_token PROTO ((const char **, unsigned *, struct parse *));
enum dhcp_token peek_token PROTO ((const char **, struct parse *)); enum dhcp_token peek_token PROTO ((const char **, unsigned *, struct parse *));
/* confpars.c */ /* confpars.c */
void parse_trace_setup (void); void parse_trace_setup (void);
@@ -1132,7 +1133,7 @@ struct enumeration_value *find_enumeration_value (const char *, int,
void skip_to_semi PROTO ((struct parse *)); void skip_to_semi PROTO ((struct parse *));
void skip_to_rbrace PROTO ((struct parse *, int)); void skip_to_rbrace PROTO ((struct parse *, int));
int parse_semi PROTO ((struct parse *)); int parse_semi PROTO ((struct parse *));
char *parse_string PROTO ((struct parse *)); int parse_string PROTO ((struct parse *, char **, unsigned *));
char *parse_host_name PROTO ((struct parse *)); char *parse_host_name PROTO ((struct parse *));
int parse_ip_addr_or_hostname PROTO ((struct expression **, int parse_ip_addr_or_hostname PROTO ((struct expression **,
struct parse *, int)); struct parse *, int));

View File

@@ -43,7 +43,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: confpars.c,v 1.134 2001/03/01 18:17:07 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n"; "$Id: confpars.c,v 1.135 2001/03/17 00:47:39 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@@ -238,14 +238,14 @@ isc_result_t conf_file_subparse (struct parse *cfile, struct group *group,
int status; int status;
do { do {
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == END_OF_FILE) if (token == END_OF_FILE)
break; break;
declaration = parse_statement (cfile, group, group_type, declaration = parse_statement (cfile, group, group_type,
(struct host_decl *)0, (struct host_decl *)0,
declaration); declaration);
} while (1); } while (1);
token = next_token (&val, cfile); /* Clear the peek buffer */ token = next_token (&val, (unsigned *)0, cfile);
status = cfile -> warnings_occurred ? ISC_R_BADPARSE : ISC_R_SUCCESS; status = cfile -> warnings_occurred ? ISC_R_BADPARSE : ISC_R_SUCCESS;
return status; return status;
@@ -263,7 +263,7 @@ isc_result_t lease_file_subparse (struct parse *cfile)
isc_result_t status; isc_result_t status;
do { do {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token == END_OF_FILE) if (token == END_OF_FILE)
break; break;
if (token == LEASE) { if (token == LEASE) {
@@ -348,12 +348,12 @@ int parse_statement (cfile, group, type, host_decl, declaration)
int known; int known;
isc_result_t status; isc_result_t status;
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
switch (token) { switch (token) {
case INCLUDE: case INCLUDE:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != STRING) { if (token != STRING) {
parse_warn (cfile, "filename string expected."); parse_warn (cfile, "filename string expected.");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -366,7 +366,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
return 1; return 1;
case HOST: case HOST:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
if (type != HOST_DECL && type != CLASS_DECL) if (type != HOST_DECL && type != CLASS_DECL)
parse_host_declaration (cfile, group); parse_host_declaration (cfile, group);
else { else {
@@ -377,7 +377,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
return 1; return 1;
case GROUP: case GROUP:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
if (type != HOST_DECL && type != CLASS_DECL) if (type != HOST_DECL && type != CLASS_DECL)
parse_group_declaration (cfile, group); parse_group_declaration (cfile, group);
else { else {
@@ -388,12 +388,12 @@ int parse_statement (cfile, group, type, host_decl, declaration)
return 1; return 1;
case TIMESTAMP: case TIMESTAMP:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
parsed_time = parse_timestamp (cfile); parsed_time = parse_timestamp (cfile);
break; break;
case SHARED_NETWORK: case SHARED_NETWORK:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
if (type == SHARED_NET_DECL || if (type == SHARED_NET_DECL ||
type == HOST_DECL || type == HOST_DECL ||
type == SUBNET_DECL || type == SUBNET_DECL ||
@@ -408,7 +408,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
return 1; return 1;
case SUBNET: case SUBNET:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
if (type == HOST_DECL || type == SUBNET_DECL || if (type == HOST_DECL || type == SUBNET_DECL ||
type == CLASS_DECL) { type == CLASS_DECL) {
parse_warn (cfile, parse_warn (cfile,
@@ -462,7 +462,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
return 1; return 1;
case VENDOR_CLASS: case VENDOR_CLASS:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
if (type == CLASS_DECL) { if (type == CLASS_DECL) {
parse_warn (cfile, parse_warn (cfile,
"class declarations not allowed here."); "class declarations not allowed here.");
@@ -473,7 +473,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
return 1; return 1;
case USER_CLASS: case USER_CLASS:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
if (type == CLASS_DECL) { if (type == CLASS_DECL) {
parse_warn (cfile, parse_warn (cfile,
"class declarations not allowed here."); "class declarations not allowed here.");
@@ -484,7 +484,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
return 1; return 1;
case CLASS: case CLASS:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
if (type == CLASS_DECL) { if (type == CLASS_DECL) {
parse_warn (cfile, parse_warn (cfile,
"class declarations not allowed here."); "class declarations not allowed here.");
@@ -495,7 +495,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
return 1; return 1;
case SUBCLASS: case SUBCLASS:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
if (type == CLASS_DECL) { if (type == CLASS_DECL) {
parse_warn (cfile, parse_warn (cfile,
"class declarations not allowed here."); "class declarations not allowed here.");
@@ -506,7 +506,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
return 1; return 1;
case HARDWARE: case HARDWARE:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
memset (&hardware, 0, sizeof hardware); memset (&hardware, 0, sizeof hardware);
parse_hardware_param (cfile, &hardware); parse_hardware_param (cfile, &hardware);
if (host_decl) if (host_decl)
@@ -517,7 +517,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
break; break;
case FIXED_ADDR: case FIXED_ADDR:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
cache = (struct option_cache *)0; cache = (struct option_cache *)0;
if (parse_fixed_addr_param (&cache, cfile)) { if (parse_fixed_addr_param (&cache, cfile)) {
if (host_decl) if (host_decl)
@@ -532,7 +532,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
break; break;
case POOL: case POOL:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
if (type != SUBNET_DECL && type != SHARED_NET_DECL) { if (type != SUBNET_DECL && type != SHARED_NET_DECL) {
parse_warn (cfile, "pool declared outside of network"); parse_warn (cfile, "pool declared outside of network");
} }
@@ -543,7 +543,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
return declaration; return declaration;
case RANGE: case RANGE:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
if (type != SUBNET_DECL || !group -> subnet) { if (type != SUBNET_DECL || !group -> subnet) {
parse_warn (cfile, parse_warn (cfile,
"range declaration not allowed here."); "range declaration not allowed here.");
@@ -554,8 +554,8 @@ int parse_statement (cfile, group, type, host_decl, declaration)
return declaration; return declaration;
case TOKEN_NOT: case TOKEN_NOT:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
switch (token) { switch (token) {
case AUTHORITATIVE: case AUTHORITATIVE:
group -> authoritative = 0; group -> authoritative = 0;
@@ -567,7 +567,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
} }
break; break;
case AUTHORITATIVE: case AUTHORITATIVE:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
group -> authoritative = 1; group -> authoritative = 1;
authoritative: authoritative:
if (type == HOST_DECL) if (type == HOST_DECL)
@@ -579,12 +579,12 @@ int parse_statement (cfile, group, type, host_decl, declaration)
"option dhcp-server-identifier". */ "option dhcp-server-identifier". */
case SERVER_IDENTIFIER: case SERVER_IDENTIFIER:
option = dhcp_universe.options [DHO_DHCP_SERVER_IDENTIFIER]; option = dhcp_universe.options [DHO_DHCP_SERVER_IDENTIFIER];
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
goto finish_option; goto finish_option;
case OPTION: case OPTION:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == SPACE) { if (token == SPACE) {
if (type != ROOT_GROUP) { if (type != ROOT_GROUP) {
parse_warn (cfile, parse_warn (cfile,
@@ -600,7 +600,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
known = 0; known = 0;
option = parse_option_name (cfile, 1, &known); option = parse_option_name (cfile, 1, &known);
if (option) { if (option) {
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == CODE) { if (token == CODE) {
if (type != ROOT_GROUP) { if (type != ROOT_GROUP) {
parse_warn (cfile, parse_warn (cfile,
@@ -610,7 +610,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
free_option (option, MDL); free_option (option, MDL);
break; break;
} }
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
if (!parse_option_code_definition (cfile, if (!parse_option_code_definition (cfile,
option)) option))
free_option (option, MDL); free_option (option, MDL);
@@ -648,7 +648,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
skip_to_semi (cfile); skip_to_semi (cfile);
break; break;
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
#if defined (FAILOVER_PROTOCOL) #if defined (FAILOVER_PROTOCOL)
parse_failover_peer (cfile, group, type); parse_failover_peer (cfile, group, type);
#else #else
@@ -736,14 +736,14 @@ void parse_failover_peer (cfile, group, type)
isc_result_t status; isc_result_t status;
dhcp_failover_config_t *cp; dhcp_failover_config_t *cp;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != PEER) { if (token != PEER) {
parse_warn (cfile, "expecting \"peer\""); parse_warn (cfile, "expecting \"peer\"");
skip_to_semi (cfile); skip_to_semi (cfile);
return; return;
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (is_identifier (token) || token == STRING) { if (is_identifier (token) || token == STRING) {
name = dmalloc (strlen (val) + 1, MDL); name = dmalloc (strlen (val) + 1, MDL);
if (!name) if (!name)
@@ -759,7 +759,7 @@ void parse_failover_peer (cfile, group, type)
peer = (dhcp_failover_state_t *)0; peer = (dhcp_failover_state_t *)0;
find_failover_peer (&peer, name, MDL); find_failover_peer (&peer, name, MDL);
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token == SEMI) { if (token == SEMI) {
dfree (name, MDL); dfree (name, MDL);
if (type != SHARED_NET_DECL) if (type != SHARED_NET_DECL)
@@ -816,7 +816,7 @@ void parse_failover_peer (cfile, group, type)
do { do {
cp = &peer -> me; cp = &peer -> me;
peer: peer:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
switch (token) { switch (token) {
case RBRACE: case RBRACE:
break; break;
@@ -851,7 +851,7 @@ void parse_failover_peer (cfile, group, type)
break; break;
case PORT: case PORT:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != NUMBER) { if (token != NUMBER) {
parse_warn (cfile, "expecting number"); parse_warn (cfile, "expecting number");
skip_to_rbrace (cfile, 1); skip_to_rbrace (cfile, 1);
@@ -862,7 +862,7 @@ void parse_failover_peer (cfile, group, type)
case MAX_RESPONSE_DELAY: case MAX_RESPONSE_DELAY:
tp = &cp -> max_response_delay; tp = &cp -> max_response_delay;
parse_idle: parse_idle:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != NUMBER) { if (token != NUMBER) {
parse_warn (cfile, "expecting number."); parse_warn (cfile, "expecting number.");
skip_to_rbrace (cfile, 1); skip_to_rbrace (cfile, 1);
@@ -908,7 +908,7 @@ void parse_failover_peer (cfile, group, type)
break; break;
case SPLIT: case SPLIT:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (peer -> i_am == secondary) if (peer -> i_am == secondary)
parse_warn (cfile, parse_warn (cfile,
"secondary may not define %s", "secondary may not define %s",
@@ -934,24 +934,24 @@ void parse_failover_peer (cfile, group, type)
break; break;
case LOAD: case LOAD:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != BALANCE) { if (token != BALANCE) {
parse_warn (cfile, "expecting 'balance'"); parse_warn (cfile, "expecting 'balance'");
badload: badload:
skip_to_rbrace (cfile, 1); skip_to_rbrace (cfile, 1);
break; break;
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != TOKEN_MAX) { if (token != TOKEN_MAX) {
parse_warn (cfile, "expecting 'max'"); parse_warn (cfile, "expecting 'max'");
goto badload; goto badload;
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != SECONDS) { if (token != SECONDS) {
parse_warn (cfile, "expecting 'secs'"); parse_warn (cfile, "expecting 'secs'");
goto badload; goto badload;
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != NUMBER) { if (token != NUMBER) {
parse_warn (cfile, "expecting number"); parse_warn (cfile, "expecting number");
goto badload; goto badload;
@@ -998,14 +998,14 @@ void parse_failover_state_declaration (struct parse *cfile,
dhcp_failover_config_t *cp; dhcp_failover_config_t *cp;
if (!peer) { if (!peer) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != PEER) { if (token != PEER) {
parse_warn (cfile, "expecting \"peer\""); parse_warn (cfile, "expecting \"peer\"");
skip_to_semi (cfile); skip_to_semi (cfile);
return; return;
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (is_identifier (token) || token == STRING) { if (is_identifier (token) || token == STRING) {
name = dmalloc (strlen (val) + 1, MDL); name = dmalloc (strlen (val) + 1, MDL);
if (!name) if (!name)
@@ -1027,7 +1027,7 @@ void parse_failover_state_declaration (struct parse *cfile,
return; return;
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != STATE) { if (token != STATE) {
parse_warn (cfile, "expecting 'state'"); parse_warn (cfile, "expecting 'state'");
if (token != SEMI) if (token != SEMI)
@@ -1038,7 +1038,7 @@ void parse_failover_state_declaration (struct parse *cfile,
state = (dhcp_failover_state_t *)0; state = (dhcp_failover_state_t *)0;
dhcp_failover_state_reference (&state, peer, MDL); dhcp_failover_state_reference (&state, peer, MDL);
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != LBRACE) { if (token != LBRACE) {
parse_warn (cfile, "expecting left brace"); parse_warn (cfile, "expecting left brace");
if (token != SEMI) if (token != SEMI)
@@ -1047,14 +1047,14 @@ void parse_failover_state_declaration (struct parse *cfile,
return; return;
} }
do { do {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
switch (token) { switch (token) {
case RBRACE: case RBRACE:
break; break;
case MY: case MY:
cp = &state -> me; cp = &state -> me;
do_state: do_state:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != STATE) { if (token != STATE) {
parse_warn (cfile, "expecting 'state'"); parse_warn (cfile, "expecting 'state'");
goto bogus; goto bogus;
@@ -1088,7 +1088,7 @@ void parse_failover_state (cfile, state, stos)
enum failover_state state_in; enum failover_state state_in;
TIME stos_in; TIME stos_in;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
switch (token) { switch (token) {
case UNKNOWN_STATE: case UNKNOWN_STATE:
state_in = unknown_state; state_in = unknown_state;
@@ -1140,7 +1140,7 @@ void parse_failover_state (cfile, state, stos)
return; return;
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != AT) { if (token != AT) {
parse_warn (cfile, "expecting \"at\""); parse_warn (cfile, "expecting \"at\"");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -1204,13 +1204,14 @@ void parse_pool_statement (cfile, group, type)
} }
do { do {
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
switch (token) { switch (token) {
case NO: case NO:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != FAILOVER || if (token != FAILOVER ||
(token = next_token (&val, cfile)) != PEER) { (token = next_token (&val, (unsigned *)0,
cfile)) != PEER) {
parse_warn (cfile, parse_warn (cfile,
"expecting \"failover peer\"."); "expecting \"failover peer\".");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -1225,14 +1226,14 @@ void parse_pool_statement (cfile, group, type)
#if defined (FAILOVER_PROTOCOL) #if defined (FAILOVER_PROTOCOL)
case FAILOVER: case FAILOVER:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != PEER) { if (token != PEER) {
parse_warn (cfile, "expecting 'peer'."); parse_warn (cfile, "expecting 'peer'.");
skip_to_semi (cfile); skip_to_semi (cfile);
break; break;
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != STRING) { if (token != STRING) {
parse_warn (cfile, "expecting string."); parse_warn (cfile, "expecting string.");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -1252,7 +1253,7 @@ void parse_pool_statement (cfile, group, type)
#endif #endif
case RANGE: case RANGE:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
parse_address_range (cfile, group, type, pool); parse_address_range (cfile, group, type, pool);
break; break;
case ALLOW: case ALLOW:
@@ -1261,13 +1262,14 @@ void parse_pool_statement (cfile, group, type)
permit = new_permit (MDL); permit = new_permit (MDL);
if (!permit) if (!permit)
log_fatal ("no memory for permit"); log_fatal ("no memory for permit");
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
switch (token) { switch (token) {
case UNKNOWN: case UNKNOWN:
permit -> type = permit_unknown_clients; permit -> type = permit_unknown_clients;
get_clients: get_clients:
if (next_token (&val, cfile) != CLIENTS) { if (next_token (&val, (unsigned *)0,
cfile) != CLIENTS) {
parse_warn (cfile, parse_warn (cfile,
"expecting \"clients\""); "expecting \"clients\"");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -1300,7 +1302,8 @@ void parse_pool_statement (cfile, group, type)
case DYNAMIC: case DYNAMIC:
permit -> type = permit_dynamic_bootp_clients; permit -> type = permit_dynamic_bootp_clients;
if (next_token (&val, cfile) != TOKEN_BOOTP) { if (next_token (&val, (unsigned *)0,
cfile) != TOKEN_BOOTP) {
parse_warn (cfile, parse_warn (cfile,
"expecting \"bootp\""); "expecting \"bootp\"");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -1310,13 +1313,15 @@ void parse_pool_statement (cfile, group, type)
goto get_clients; goto get_clients;
case MEMBERS: case MEMBERS:
if (next_token (&val, cfile) != OF) { if (next_token (&val, (unsigned *)0,
cfile) != OF) {
parse_warn (cfile, "expecting \"of\""); parse_warn (cfile, "expecting \"of\"");
skip_to_semi (cfile); skip_to_semi (cfile);
free_permit (permit, MDL); free_permit (permit, MDL);
continue; continue;
} }
if (next_token (&val, cfile) != STRING) { if (next_token (&val, (unsigned *)0,
cfile) != STRING) {
parse_warn (cfile, parse_warn (cfile,
"expecting class name."); "expecting class name.");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -1347,7 +1352,7 @@ void parse_pool_statement (cfile, group, type)
goto get_permit; goto get_permit;
case RBRACE: case RBRACE:
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
done = 1; done = 1;
break; break;
@@ -1416,7 +1421,7 @@ int parse_boolean (cfile)
const char *val; const char *val;
int rv; int rv;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (!strcasecmp (val, "true") if (!strcasecmp (val, "true")
|| !strcasecmp (val, "on")) || !strcasecmp (val, "on"))
rv = 1; rv = 1;
@@ -1442,7 +1447,7 @@ int parse_lbrace (cfile)
enum dhcp_token token; enum dhcp_token token;
const char *val; const char *val;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != LBRACE) { if (token != LBRACE) {
parse_warn (cfile, "expecting left brace."); parse_warn (cfile, "expecting left brace.");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -1491,13 +1496,13 @@ void parse_host_declaration (cfile, group)
goto boom; goto boom;
do { do {
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == RBRACE) { if (token == RBRACE) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
break; break;
} }
if (token == END_OF_FILE) { if (token == END_OF_FILE) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
parse_warn (cfile, "unexpected end of file"); parse_warn (cfile, "unexpected end of file");
break; break;
} }
@@ -1505,7 +1510,7 @@ void parse_host_declaration (cfile, group)
remember to save it. */ remember to save it. */
if (token == DYNAMIC) { if (token == DYNAMIC) {
dynamicp = 1; dynamicp = 1;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (!parse_semi (cfile)) if (!parse_semi (cfile))
break; break;
continue; continue;
@@ -1514,7 +1519,7 @@ void parse_host_declaration (cfile, group)
remember to save it. */ remember to save it. */
if (token == TOKEN_DELETED) { if (token == TOKEN_DELETED) {
deleted = 1; deleted = 1;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (!parse_semi (cfile)) if (!parse_semi (cfile))
break; break;
continue; continue;
@@ -1522,8 +1527,8 @@ void parse_host_declaration (cfile, group)
if (token == GROUP) { if (token == GROUP) {
struct group_object *go; struct group_object *go;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != STRING && !is_identifier (token)) { if (token != STRING && !is_identifier (token)) {
parse_warn (cfile, parse_warn (cfile,
"expecting string or identifier."); "expecting string or identifier.");
@@ -1553,15 +1558,14 @@ void parse_host_declaration (cfile, group)
unsigned char *t = 0; unsigned char *t = 0;
unsigned len; unsigned len;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
data_string_forget (&host -> client_identifier, MDL); data_string_forget (&host -> client_identifier, MDL);
/* See if it's a string or a cshl. */ /* See if it's a string or a cshl. */
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == STRING) { if (token == STRING) {
token = next_token (&val, cfile); token = next_token (&val, &len, cfile);
s = val; s = val;
len = strlen (val);
host -> client_identifier.terminated = 1; host -> client_identifier.terminated = 1;
} else { } else {
len = 0; len = 0;
@@ -1658,7 +1662,7 @@ int parse_class_declaration (cp, cfile, group, type)
int new = 1; int new = 1;
isc_result_t status; isc_result_t status;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != STRING) { if (token != STRING) {
parse_warn (cfile, "Expecting class name"); parse_warn (cfile, "Expecting class name");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -1715,10 +1719,9 @@ int parse_class_declaration (cp, cfile, group, type)
/* If this is a straight subclass, parse the hash string. */ /* If this is a straight subclass, parse the hash string. */
if (type == 3) { if (type == 3) {
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == STRING) { if (token == STRING) {
token = next_token (&val, cfile); token = next_token (&val, &data.len, cfile);
data.len = strlen (val);
data.buffer = (struct buffer *)0; data.buffer = (struct buffer *)0;
if (!buffer_allocate (&data.buffer, if (!buffer_allocate (&data.buffer,
data.len + 1, MDL)) { data.len + 1, MDL)) {
@@ -1729,7 +1732,8 @@ int parse_class_declaration (cp, cfile, group, type)
} }
data.terminated = 1; data.terminated = 1;
data.data = &data.buffer -> data [0]; data.data = &data.buffer -> data [0];
strcpy ((char *)data.buffer -> data, val); memcpy ((char *)data.buffer -> data, val,
data.len + 1);
} else if (token == NUMBER_OR_NAME || token == NUMBER) { } else if (token == NUMBER_OR_NAME || token == NUMBER) {
memset (&data, 0, sizeof data); memset (&data, 0, sizeof data);
if (!parse_cshl (&data, cfile)) { if (!parse_cshl (&data, cfile)) {
@@ -1812,9 +1816,9 @@ int parse_class_declaration (cp, cfile, group, type)
/* Spawned classes don't have to have their own settings. */ /* Spawned classes don't have to have their own settings. */
if (class -> superclass) { if (class -> superclass) {
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == SEMI) { if (token == SEMI) {
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
if (cp) if (cp)
status = class_reference (cp, class, MDL); status = class_reference (cp, class, MDL);
class_dereference (&class, MDL); class_dereference (&class, MDL);
@@ -1834,12 +1838,12 @@ int parse_class_declaration (cp, cfile, group, type)
} }
do { do {
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == RBRACE) { if (token == RBRACE) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
break; break;
} else if (token == END_OF_FILE) { } else if (token == END_OF_FILE) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
parse_warn (cfile, "unexpected end of file"); parse_warn (cfile, "unexpected end of file");
break; break;
} else if (token == MATCH) { } else if (token == MATCH) {
@@ -1854,11 +1858,11 @@ int parse_class_declaration (cp, cfile, group, type)
skip_to_semi (cfile); skip_to_semi (cfile);
break; break;
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token != IF) if (token != IF)
goto submatch; goto submatch;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (!parse_boolean_expression (&class -> expr, cfile, if (!parse_boolean_expression (&class -> expr, cfile,
&lose)) { &lose)) {
if (!lose) { if (!lose) {
@@ -1880,9 +1884,9 @@ int parse_class_declaration (cp, cfile, group, type)
skip_to_semi (cfile); skip_to_semi (cfile);
break; break;
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
class -> spawning = 1; class -> spawning = 1;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != WITH) { if (token != WITH) {
parse_warn (cfile, parse_warn (cfile,
"expecting with after spawn"); "expecting with after spawn");
@@ -1912,15 +1916,15 @@ int parse_class_declaration (cp, cfile, group, type)
parse_semi (cfile); parse_semi (cfile);
} }
} else if (token == LEASE) { } else if (token == LEASE) {
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != LIMIT) { if (token != LIMIT) {
parse_warn (cfile, "expecting \"limit\""); parse_warn (cfile, "expecting \"limit\"");
if (token != SEMI) if (token != SEMI)
skip_to_semi (cfile); skip_to_semi (cfile);
break; break;
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != NUMBER) { if (token != NUMBER) {
parse_warn (cfile, "expecting a number"); parse_warn (cfile, "expecting a number");
if (token != SEMI) if (token != SEMI)
@@ -1988,9 +1992,9 @@ void parse_shared_net_declaration (cfile, group)
share, MDL); share, MDL);
/* Get the name of the shared network... */ /* Get the name of the shared network... */
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == STRING) { if (token == STRING) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (val [0] == 0) { if (val [0] == 0) {
parse_warn (cfile, "zero-length shared network name"); parse_warn (cfile, "zero-length shared network name");
@@ -2018,9 +2022,9 @@ void parse_shared_net_declaration (cfile, group)
} }
do { do {
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == RBRACE) { if (token == RBRACE) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (!share -> subnets) if (!share -> subnets)
parse_warn (cfile, parse_warn (cfile,
"empty shared-network decl"); "empty shared-network decl");
@@ -2029,12 +2033,12 @@ void parse_shared_net_declaration (cfile, group)
shared_network_dereference (&share, MDL); shared_network_dereference (&share, MDL);
return; return;
} else if (token == END_OF_FILE) { } else if (token == END_OF_FILE) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
parse_warn (cfile, "unexpected end of file"); parse_warn (cfile, "unexpected end of file");
break; break;
} else if (token == INTERFACE) { } else if (token == INTERFACE) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
new_shared_network_interface (cfile, share, val); new_shared_network_interface (cfile, share, val);
if (!parse_semi (cfile)) if (!parse_semi (cfile))
break; break;
@@ -2085,7 +2089,7 @@ void parse_subnet_declaration (cfile, share)
iaddr.len = len; iaddr.len = len;
subnet -> net = iaddr; subnet -> net = iaddr;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != NETMASK) { if (token != NETMASK) {
parse_warn (cfile, "Expecting netmask"); parse_warn (cfile, "Expecting netmask");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -2119,17 +2123,17 @@ void parse_subnet_declaration (cfile, share)
} }
do { do {
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == RBRACE) { if (token == RBRACE) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
break; break;
} else if (token == END_OF_FILE) { } else if (token == END_OF_FILE) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
parse_warn (cfile, "unexpected end of file"); parse_warn (cfile, "unexpected end of file");
break; break;
} else if (token == INTERFACE) { } else if (token == INTERFACE) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
new_shared_network_interface (cfile, share, val); new_shared_network_interface (cfile, share, val);
if (!parse_semi (cfile)) if (!parse_semi (cfile))
break; break;
@@ -2193,9 +2197,9 @@ void parse_group_declaration (cfile, group)
if (!clone_group (&g, group, MDL)) if (!clone_group (&g, group, MDL))
log_fatal ("no memory for explicit group."); log_fatal ("no memory for explicit group.");
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (is_identifier (token) || token == STRING) { if (is_identifier (token) || token == STRING) {
next_token (&val, cfile); next_token (&val, (unsigned *)0, cfile);
name = dmalloc (strlen (val) + 1, MDL); name = dmalloc (strlen (val) + 1, MDL);
if (!name) if (!name)
@@ -2209,24 +2213,24 @@ void parse_group_declaration (cfile, group)
} }
do { do {
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == RBRACE) { if (token == RBRACE) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
break; break;
} else if (token == END_OF_FILE) { } else if (token == END_OF_FILE) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
parse_warn (cfile, "unexpected end of file"); parse_warn (cfile, "unexpected end of file");
break; break;
} else if (token == TOKEN_DELETED) { } else if (token == TOKEN_DELETED) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
parse_semi (cfile); parse_semi (cfile);
deletedp = 1; deletedp = 1;
} else if (token == DYNAMIC) { } else if (token == DYNAMIC) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
parse_semi (cfile); parse_semi (cfile);
dynamicp = 1; dynamicp = 1;
} else if (token == STATIC) { } else if (token == STATIC) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
parse_semi (cfile); parse_semi (cfile);
staticp = 1; staticp = 1;
} }
@@ -2295,9 +2299,9 @@ int parse_fixed_addr_param (oc, cfile)
expression_dereference (&expr, MDL); expression_dereference (&expr, MDL);
return 0; return 0;
} }
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == COMMA) if (token == COMMA)
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
} while (token == COMMA); } while (token == COMMA);
if (!parse_semi (cfile)) { if (!parse_semi (cfile)) {
@@ -2364,6 +2368,7 @@ int parse_lease_declaration (struct lease **lp, struct parse *cfile)
struct option_cache *oc; struct option_cache *oc;
pair *p; pair *p;
binding_state_t new_state; binding_state_t new_state;
unsigned buflen = 0;
lease = (struct lease *)0; lease = (struct lease *)0;
status = lease_allocate (&lease, MDL); status = lease_allocate (&lease, MDL);
@@ -2384,7 +2389,7 @@ int parse_lease_declaration (struct lease **lp, struct parse *cfile)
} }
do { do {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token == RBRACE) if (token == RBRACE)
break; break;
else if (token == END_OF_FILE) { else if (token == END_OF_FILE) {
@@ -2442,26 +2447,31 @@ int parse_lease_declaration (struct lease **lp, struct parse *cfile)
/* Colon-seperated hexadecimal octets... */ /* Colon-seperated hexadecimal octets... */
case UID: case UID:
seenbit = 8; seenbit = 8;
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == STRING) { if (token == STRING) {
unsigned char *tuid; unsigned char *tuid;
token = next_token (&val, cfile); token = next_token (&val, &buflen, cfile);
lease -> uid_len = strlen (val); lease -> uid_len = buflen;
tuid = ((unsigned char *) if (buflen < sizeof lease -> uid_buf)
dmalloc (lease -> uid_len, MDL)); tuid = lease -> uid_buf;
if (!tuid) { else {
log_error ("no space for uid"); tuid = ((unsigned char *)
lease_dereference (&lease, MDL); dmalloc (buflen, MDL));
return 0; if (!tuid) {
log_error ("no space for uid");
lease_dereference (&lease,
MDL);
return 0;
}
} }
memcpy (tuid, val, lease -> uid_len); memcpy (tuid, val, lease -> uid_len);
lease -> uid = tuid; lease -> uid = tuid;
} else { } else {
unsigned uid_len = 0; buflen = 0;
lease -> uid = (parse_numeric_aggregate lease -> uid = (parse_numeric_aggregate
(cfile, (unsigned char *)0, (cfile, (unsigned char *)0,
&uid_len, ':', 16, 8)); &buflen, ':', 16, 8));
lease -> uid_len = uid_len; lease -> uid_len = buflen;
if (!lease -> uid) { if (!lease -> uid) {
lease_dereference (&lease, MDL); lease_dereference (&lease, MDL);
return 0; return 0;
@@ -2482,7 +2492,7 @@ int parse_lease_declaration (struct lease **lp, struct parse *cfile)
case CLASS: case CLASS:
seenbit = 32; seenbit = 32;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (!is_identifier (token)) { if (!is_identifier (token)) {
if (token != SEMI) if (token != SEMI)
skip_to_rbrace (cfile, 1); skip_to_rbrace (cfile, 1);
@@ -2515,7 +2525,7 @@ int parse_lease_declaration (struct lease **lp, struct parse *cfile)
case TOKEN_NEXT: case TOKEN_NEXT:
seenbit = 128; seenbit = 128;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != BINDING) { if (token != BINDING) {
parse_warn (cfile, "expecting 'binding'"); parse_warn (cfile, "expecting 'binding'");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -2527,13 +2537,13 @@ int parse_lease_declaration (struct lease **lp, struct parse *cfile)
seenbit = 256; seenbit = 256;
do_binding_state: do_binding_state:
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != STATE) { if (token != STATE) {
parse_warn (cfile, "expecting 'state'"); parse_warn (cfile, "expecting 'state'");
skip_to_semi (cfile); skip_to_semi (cfile);
break; break;
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
switch (token) { switch (token) {
case TOKEN_ABANDONED: case TOKEN_ABANDONED:
new_state = FTS_ABANDONED; new_state = FTS_ABANDONED;
@@ -2585,30 +2595,35 @@ int parse_lease_declaration (struct lease **lp, struct parse *cfile)
case CLIENT_HOSTNAME: case CLIENT_HOSTNAME:
seenbit = 1024; seenbit = 1024;
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == STRING) if (token == STRING) {
lease -> client_hostname = if (!parse_string (cfile,
parse_string (cfile); &lease -> client_hostname,
else { (unsigned *)0)) {
lease_dereference (&lease, MDL);
return 0;
}
} else {
lease -> client_hostname = lease -> client_hostname =
parse_host_name (cfile); parse_host_name (cfile);
if (lease -> client_hostname) if (lease -> client_hostname)
parse_semi (cfile); parse_semi (cfile);
} else {
if (!lease -> client_hostname) { parse_warn (cfile,
parse_warn (cfile, "expecting a hostname."); "expecting a hostname.");
skip_to_semi (cfile); skip_to_semi (cfile);
seenbit = 0; lease_dereference (&lease, MDL);
lease_dereference (&lease, MDL); return 0;
return 0; }
} }
break; break;
case BILLING: case BILLING:
seenbit = 2048; seenbit = 2048;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token == CLASS) { if (token == CLASS) {
token = next_token (&val, cfile); token = next_token (&val,
(unsigned *)0, cfile);
if (token != STRING) { if (token != STRING) {
parse_warn (cfile, "expecting string"); parse_warn (cfile, "expecting string");
if (token != SEMI) if (token != SEMI)
@@ -2692,7 +2707,7 @@ int parse_lease_declaration (struct lease **lp, struct parse *cfile)
case TOKEN_SET: case TOKEN_SET:
noequal = 0; noequal = 0;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != NAME && token != NUMBER_OR_NAME) { if (token != NAME && token != NUMBER_OR_NAME) {
parse_warn (cfile, parse_warn (cfile,
"%s can't be a variable name", "%s can't be a variable name",
@@ -2735,7 +2750,7 @@ int parse_lease_declaration (struct lease **lp, struct parse *cfile)
log_fatal ("no memory for binding value."); log_fatal ("no memory for binding value.");
if (!noequal) { if (!noequal) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != EQUAL) { if (token != EQUAL) {
parse_warn (cfile, parse_warn (cfile,
"expecting '=' in set statement."); "expecting '=' in set statement.");
@@ -2743,20 +2758,20 @@ int parse_lease_declaration (struct lease **lp, struct parse *cfile)
} }
} }
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == STRING) { if (token == STRING) {
unsigned char *tuid; unsigned char *tuid;
token = next_token (&val, cfile); token = next_token (&val, &buflen, cfile);
binding -> value -> type = binding_data; binding -> value -> type = binding_data;
binding -> value -> value.data.len = strlen (val); binding -> value -> value.data.len = buflen;
if (!(buffer_allocate if (!(buffer_allocate
(&binding -> value -> value.data.buffer, (&binding -> value -> value.data.buffer,
binding -> value-> value.data.len + 1, buflen + 1, MDL)))
MDL)))
log_fatal ("No memory for binding."); log_fatal ("No memory for binding.");
strcpy ((char *) memcpy ((char *)
(binding -> value -> (binding -> value ->
value.data.buffer -> data), val); value.data.buffer -> data),
val, buflen + 1);
binding -> value -> value.data.data = binding -> value -> value.data.data =
binding -> value -> value.data.buffer -> data; binding -> value -> value.data.buffer -> data;
binding -> value -> value.data.terminated = 1; binding -> value -> value.data.terminated = 1;
@@ -2787,8 +2802,8 @@ int parse_lease_declaration (struct lease **lp, struct parse *cfile)
binding -> value -> value.data.buffer -> data; binding -> value -> value.data.buffer -> data;
} }
} else if (token == PERCENT) { } else if (token == PERCENT) {
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != NUMBER) { if (token != NUMBER) {
parse_warn (cfile, parse_warn (cfile,
"expecting decimal number."); "expecting decimal number.");
@@ -2802,7 +2817,8 @@ int parse_lease_declaration (struct lease **lp, struct parse *cfile)
binding -> value -> type = binding_numeric; binding -> value -> type = binding_numeric;
binding -> value -> value.intval = atol (val); binding -> value -> value.intval = atol (val);
} else if (token == NAME) { } else if (token == NAME) {
token = next_token (&val, cfile); token = next_token (&val,
(unsigned *)0, cfile);
binding -> value -> type = binding_boolean; binding -> value -> type = binding_boolean;
if (!strcasecmp (val, "true")) if (!strcasecmp (val, "true"))
binding -> value -> value.boolean = 1; binding -> value -> value.boolean = 1;
@@ -2901,8 +2917,9 @@ void parse_address_range (cfile, group, type, inpool)
struct pool *pool; struct pool *pool;
isc_result_t status; isc_result_t status;
if ((token = peek_token (&val, cfile)) == DYNAMIC_BOOTP) { if ((token = peek_token (&val,
token = next_token (&val, cfile); (unsigned *)0, cfile)) == DYNAMIC_BOOTP) {
token = next_token (&val, (unsigned *)0, cfile);
dynamic = 1; dynamic = 1;
} }
@@ -2913,7 +2930,7 @@ void parse_address_range (cfile, group, type, inpool)
low.len = len; low.len = len;
/* Only one address? */ /* Only one address? */
token = peek_token (&val, cfile); token = peek_token (&val, (unsigned *)0, cfile);
if (token == SEMI) if (token == SEMI)
high = low; high = low;
else { else {
@@ -2924,7 +2941,7 @@ void parse_address_range (cfile, group, type, inpool)
high.len = len; high.len = len;
} }
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != SEMI) { if (token != SEMI) {
parse_warn (cfile, "semicolon expected."); parse_warn (cfile, "semicolon expected.");
skip_to_semi (cfile); skip_to_semi (cfile);
@@ -3063,7 +3080,7 @@ int parse_allow_deny (oc, cfile, flag)
if (!make_const_data (&data, &rf, 1, 0, 1)) if (!make_const_data (&data, &rf, 1, 0, 1))
return 0; return 0;
token = next_token (&val, cfile); token = next_token (&val, (unsigned *)0, cfile);
switch (token) { switch (token) {
case TOKEN_BOOTP: case TOKEN_BOOTP:
status = option_cache (oc, (struct data_string *)0, data, status = option_cache (oc, (struct data_string *)0, data,