diff options
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dhclient/clparse.c | 27 | ||||
-rw-r--r-- | sbin/dhclient/dhcpd.h | 4 | ||||
-rw-r--r-- | sbin/dhclient/parse.c | 24 |
3 files changed, 34 insertions, 21 deletions
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index a47df425cf8..44768316543 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clparse.c,v 1.129 2017/09/20 19:21:00 krw Exp $ */ +/* $OpenBSD: clparse.c,v 1.130 2017/10/09 21:33:11 krw Exp $ */ /* Parser for dhclient config and lease files. */ @@ -275,25 +275,32 @@ parse_client_statement(FILE *cfile, char *name) } break; case TOK_LINK_TIMEOUT: - parse_lease_time(cfile, &config->link_timeout); + if (parse_lease_time(cfile, &config->link_timeout) == 1) + parse_semi(cfile); break; case TOK_TIMEOUT: - parse_lease_time(cfile, &config->timeout); + if (parse_lease_time(cfile, &config->timeout) == 1) + parse_semi(cfile); break; case TOK_RETRY: - parse_lease_time(cfile, &config->retry_interval); + if (parse_lease_time(cfile, &config->retry_interval) == 1) + parse_semi(cfile); break; case TOK_SELECT_TIMEOUT: - parse_lease_time(cfile, &config->select_interval); + if (parse_lease_time(cfile, &config->select_interval) == 1) + parse_semi(cfile); break; case TOK_REBOOT: - parse_lease_time(cfile, &config->reboot_timeout); + if (parse_lease_time(cfile, &config->reboot_timeout) == 1) + parse_semi(cfile); break; case TOK_BACKOFF_CUTOFF: - parse_lease_time(cfile, &config->backoff_cutoff); + if (parse_lease_time(cfile, &config->backoff_cutoff) == 1) + parse_semi(cfile); break; case TOK_INITIAL_INTERVAL: - parse_lease_time(cfile, &config->initial_interval); + if (parse_lease_time(cfile, &config->initial_interval) == 1) + parse_semi(cfile); break; case TOK_INTERFACE: parse_interface_declaration(cfile, name); @@ -318,11 +325,11 @@ parse_client_statement(FILE *cfile, char *name) parse_semi(cfile); break; case TOK_FIXED_ADDR: - if (parse_ip_addr(cfile, &config->address) != 0) + if (parse_ip_addr(cfile, &config->address) == 1) parse_semi(cfile); break; case TOK_NEXT_SERVER: - if (parse_ip_addr(cfile, &config->next_server) != 0) + if (parse_ip_addr(cfile, &config->next_server) == 1) parse_semi(cfile); break; default: diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index cfbc63ca9cf..e7321af8ae1 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.228 2017/09/20 15:14:52 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.229 2017/10/09 21:33:11 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -182,7 +182,7 @@ int parse_semi(FILE *); char *parse_string(FILE *, unsigned int *); int parse_ip_addr(FILE *, struct in_addr *); int parse_cidr(FILE *, unsigned char *); -void parse_lease_time(FILE *, time_t *); +int parse_lease_time(FILE *, time_t *); int parse_decimal(FILE *, unsigned char *, char); int parse_hex(FILE *, unsigned char *); int parse_boolean(FILE *, unsigned char *); diff --git a/sbin/dhclient/parse.c b/sbin/dhclient/parse.c index afbdc690efe..2d3be889911 100644 --- a/sbin/dhclient/parse.c +++ b/sbin/dhclient/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.65 2017/10/09 18:02:43 krw Exp $ */ +/* $OpenBSD: parse.c,v 1.66 2017/10/09 21:33:11 krw Exp $ */ /* Common parser code for dhcpd and dhclient. */ @@ -233,20 +233,26 @@ parse_ip_addr(FILE *cfile, struct in_addr *addr) /* * lease-time :== NUMBER SEMI */ -void +int parse_lease_time(FILE *cfile, time_t *timep) { - uint32_t value; + const char *errstr; + char *val; + long long numval; + int token; - if (parse_decimal(cfile, (char *)&value, 'L') == 0) { - parse_warn("expecting unsigned 32-bit decimal value."); - skip_to_semi(cfile); - return; + token = next_token(&val, cfile); + numval = strtonum(val, 0, UINT32_MAX, &errstr); + if (errstr == NULL) { + *timep = numval; + return 1; } - *timep = betoh32(value); + parse_warn("expecting unsigned 32-bit decimal value."); + if (token != ';') + skip_to_semi(cfile); - parse_semi(cfile); + return 0; } int |