diff options
| author | 2015-05-18 17:51:21 +0000 | |
|---|---|---|
| committer | 2015-05-18 17:51:21 +0000 | |
| commit | 11b1f78ac67154562cb30cbdd164ae54e7e66fd6 (patch) | |
| tree | 0498081d6fe2d220f89528fad255700ea047c510 /usr.sbin/dhcpd/parse.c | |
| parent | Fix a crash reported and analyzed by Bertrand PROVOST. When a HTTP (diff) | |
| download | wireguard-openbsd-11b1f78ac67154562cb30cbdd164ae54e7e66fd6.tar.xz wireguard-openbsd-11b1f78ac67154562cb30cbdd164ae54e7e66fd6.zip | |
Tweak parsing so that hostnames starting with 0-9 are accepted.
Reported long ago by matthieu@. Also Jacob Berkman via the lists.
Tests and suggestions from Jacob and Matthieu.
Diffstat (limited to 'usr.sbin/dhcpd/parse.c')
| -rw-r--r-- | usr.sbin/dhcpd/parse.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/usr.sbin/dhcpd/parse.c b/usr.sbin/dhcpd/parse.c index c7056a58326..12c2d184e60 100644 --- a/usr.sbin/dhcpd/parse.c +++ b/usr.sbin/dhcpd/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.17 2013/12/18 20:37:04 krw Exp $ */ +/* $OpenBSD: parse.c,v 1.18 2015/05/18 17:51:21 krw Exp $ */ /* Common parser code for dhcpd and dhclient. */ @@ -40,6 +40,8 @@ * Enterprises, see ``http://www.vix.com''. */ +#include <stdint.h> + #include "dhcpd.h" #include "dhctoken.h" @@ -148,7 +150,7 @@ parse_host_name(FILE *cfile) do { /* Read a token, which should be an identifier. */ token = next_token(&val, cfile); - if (!is_identifier(token) && token != TOK_NUMBER) { + if (!is_identifier(token)) { parse_warn("expecting an identifier in hostname"); skip_to_semi(cfile); return (NULL); @@ -252,19 +254,19 @@ parse_hardware_param(FILE *cfile, struct hardware *hardware) void parse_lease_time(FILE *cfile, time_t *timep) { + const char *errstr; char *val; uint32_t value; int token; token = next_token(&val, cfile); - if (token != TOK_NUMBER) { - parse_warn("Expecting numeric lease time"); + + value = strtonum(val, 0, UINT32_MAX, &errstr); + if (errstr) { + parse_warn("lease time is %s: %s", errstr, val); skip_to_semi(cfile); return; } - convert_num((unsigned char *)&value, val, 10, 32); - /* Unswap the number - convert_num returns stuff in NBO. */ - *timep = ntohl(value); /* XXX */ parse_semi(cfile); } @@ -314,9 +316,7 @@ parse_numeric_aggregate(FILE *cfile, unsigned char *buf, int *max, parse_warn("unexpected end of file"); break; } - /* Allow NUMBER_OR_NAME if base is 16. */ - if (token != TOK_NUMBER && - (base != 16 || token != TOK_NUMBER_OR_NAME)) { + if (token != TOK_NUMBER && token != TOK_NUMBER_OR_NAME) { parse_warn("expecting numeric value."); skip_to_semi(cfile); return (NULL); @@ -484,6 +484,7 @@ parse_date(FILE *cfile) switch (token) { case TOK_NAME: case TOK_NUMBER: + case TOK_NUMBER_OR_NAME: case '/': case ':': token = next_token(&val, cfile); |
