#define PARSE_STRING_NULL 1
#define PARSE_HWADDR 2
#define parse_string(a, b, c) parse_str((a), (b), (c), PARSE_STRING)
+#define parse_nstring(a, b, c) parse_str((a), (b), (c), PARSE_STRING_NULL)
#define parse_hwaddr(a, b, c) parse_str((a), (b), (c), PARSE_HWADDR)
static ssize_t
parse_str(char *sbuf, size_t slen, const char *str, int flags)
ARG_REQUIRED;
if (ifo->script != default_script)
free(ifo->script);
- s = parse_str(NULL, 0, arg, PARSE_STRING_NULL);
+ s = parse_nstring(NULL, 0, arg);
if (s == 0) {
ifo->script = NULL;
break;
logerr(__func__);
return -1;
}
- s = parse_str(ifo->script, dl, arg, PARSE_STRING_NULL);
+ s = parse_nstring(ifo->script, dl, arg);
if (s == -1 ||
ifo->script[0] == '\0' ||
strcmp(ifo->script, "/dev/null") == 0)
ifo->options |= DHCPCD_HOSTNAME;
break;
}
- s = parse_string(ifo->hostname, HOSTNAME_MAX_LEN, arg);
+ s = parse_nstring(ifo->hostname, sizeof(ifo->hostname), arg);
if (s == -1) {
logerr("%s: hostname", __func__);
return -1;
logerrx("hostname cannot begin with .");
return -1;
}
- ifo->hostname[s] = '\0';
if (ifo->hostname[0] == '\0')
ifo->options &= ~DHCPCD_HOSTNAME;
else
}
break;
case 'u':
- s = USERCLASS_MAX_LEN - ifo->userclass[0] - 1;
+ dl = sizeof(ifo->userclass) - ifo->userclass[0] - 1;
s = parse_string((char *)ifo->userclass +
- ifo->userclass[0] + 2, (size_t)s, arg);
+ ifo->userclass[0] + 2, dl, arg);
if (s == -1) {
logerr("userclass");
return -1;