diff --git a/src/option.c b/src/option.c index 15c794e..44bd522 100644 --- a/src/option.c +++ b/src/option.c @@ -745,7 +745,7 @@ static int numeric_check(char *a) { char *p; - if (!a) + if (!a || *a == 0) return 0; unhide_metas(a); @@ -771,11 +771,14 @@ static int strtoul_check(char *a, u32 *res) if (!numeric_check(a)) return 0; + x = strtoul(a, NULL, 10); - if (errno || x > UINT32_MAX) { - errno = 0; - return 0; - } + if (errno || x > UINT32_MAX) + { + errno = 0; + return 0; + } + *res = (u32)x; return 1; } @@ -1896,7 +1899,7 @@ static int parse_dhcp_opt(char *errstr, char *arg, int flags) { /* First arg is Enterprise ID (4 bytes) subsequent are length fields (2 bytes each) + string */ - int i, commas = 1; + int enterprise, i, commas = 1; unsigned char *p, *newp; for (i = 0; comma[i]; i++) @@ -1908,14 +1911,11 @@ static int parse_dhcp_opt(char *errstr, char *arg, int flags) arg = comma; comma = split(arg); - if (arg && *arg) - { - unsigned int enterprise = atoi(arg); - PUTLONG(enterprise, p); - } + if (atoi_check(arg, &enterprise)) + PUTLONG(enterprise, p); else - goto_err(_("missing enterprise ID in dhcp-option")); - + goto_err(_("bad or missing enterprise ID in dhcp-option")); + arg = comma; comma = split(arg);