diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2017-10-09 21:33:12 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2017-10-09 21:33:12 +0000 |
commit | eb25e3a3be14a55e11aa67b8c89341646216a38d (patch) | |
tree | cb30281f0ffdec04580139e14cb7497c69dd2080 /sbin/dhclient/clparse.c | |
parent | 226698ec8f8951139c93ec33ac63385d99cce342 (diff) |
Tweak parse_lease_time() to emit a single message on
failure ("expecting unsigned 32-bit decimal value") and to
properly handle the terminating ';' in error situations.
Make parse_lease_time() return an int to indicate success
or failure as its friends do. Also avoid swapping endianess
twice.
Use == 1 vs != 0 when checking parse_ip_addr() return
value.
Diffstat (limited to 'sbin/dhclient/clparse.c')
-rw-r--r-- | sbin/dhclient/clparse.c | 27 |
1 files changed, 17 insertions, 10 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: |