#ifdef INET6
i = 0;
#endif
+
+/* Add a guard for static analysers.
+ * This should not be needed really because of the argument_required option
+ * in the options declaration above. */
+#define ARG_REQUIRED if (arg == NULL) goto arg_required
+
switch(opt) {
case 'f': /* FALLTHROUGH */
case 'g': /* FALLTHROUGH */
ifo->options |= DHCPCD_BACKGROUND;
break;
case 'c':
+ ARG_REQUIRED;
free(ifo->script);
ifo->script = strdup(arg);
if (ifo->script == NULL)
ifo->options |= DHCPCD_DEBUG;
break;
case 'e':
+ ARG_REQUIRED;
add_environ(ctx, ifo, arg, 1);
break;
case 'h':
*ifo->vendorclassid = (uint8_t)s;
break;
case 'j':
+ ARG_REQUIRED;
/* per interface logging is not supported
* don't want to overide the commandline */
if (ifname == NULL && ctx->logfile == NULL) {
ifo->options |= DHCPCD_RELEASE;
break;
case 'l':
+ ARG_REQUIRED;
ifo->leasetime = (uint32_t)strtou(arg, NULL,
0, 0, UINT32_MAX, &e);
if (e) {
}
break;
case 'm':
+ ARG_REQUIRED;
ifo->metric = (int)strtoi(arg, NULL, 0, 0, INT32_MAX, &e);
if (e) {
logger(ctx, LOG_ERR, "failed to convert metric %s", arg);
}
break;
case 'o':
+ ARG_REQUIRED;
arg = set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo,
&request, &require, &no, &reject);
if (make_option_mask(d, dl, od, odl, request, arg, 1) != 0 ||
}
break;
case O_REJECT:
+ ARG_REQUIRED;
arg = set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo,
&request, &require, &no, &reject);
if (make_option_mask(d, dl, od, odl, reject, arg, 1) != 0 ||
ifo->options |= DHCPCD_INFORM6;
break;
case 't':
+ ARG_REQUIRED;
ifo->timeout = (time_t)strtoi(arg, NULL, 0, 0, INT32_MAX, &e);
if (e) {
logger(ctx, LOG_ERR, "failed to convert timeout");
}
break;
case 'v':
+ ARG_REQUIRED;
p = strchr(arg, ',');
if (!p || !p[1]) {
logger(ctx, LOG_ERR, "invalid vendor format: %s", arg);
}
break;
case 'y':
+ ARG_REQUIRED;
ifo->reboot = (time_t)strtoi(arg, NULL, 0, 0, UINT32_MAX, &e);
if (e) {
logger(ctx, LOG_ERR, "failed to convert reboot %s", arg);
}
break;
case 'z':
+ ARG_REQUIRED;
if (ifname == NULL)
ctx->ifav = splitv(ctx, &ctx->ifac, ctx->ifav, arg);
break;
ifo->options &= ~DHCPCD_DAEMONISE;
break;
case 'C':
+ ARG_REQUIRED;
/* Commas to spaces for shell */
while ((p = strchr(arg, ',')))
*p = ' ';
ifo->options |= DHCPCD_MASTER;
break;
case 'O':
+ ARG_REQUIRED;
arg = set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo,
&request, &require, &no, &reject);
if (make_option_mask(d, dl, od, odl, request, arg, -1) != 0 ||
}
break;
case 'Q':
+ ARG_REQUIRED;
arg = set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo,
&request, &require, &no, &reject);
if (make_option_mask(d, dl, od, odl, require, arg, 1) != 0 ||
}
break;
case 'S':
+ ARG_REQUIRED;
p = strchr(arg, '=');
if (p == NULL) {
logger(ctx, LOG_ERR, "static assignment required");
ifo->blacklist[ifo->blacklist_len++] = addr2.s_addr;
break;
case 'Z':
+ ARG_REQUIRED;
if (ifname == NULL)
ctx->ifdv = splitv(ctx, &ctx->ifdc, ctx->ifdv, arg);
break;
}
break;
case O_DESTINATION:
+ ARG_REQUIRED;
arg = set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo,
&request, &require, &no, &reject);
if (make_option_mask(d, dl, od, odl,
}
break;
case O_FALLBACK:
+ ARG_REQUIRED;
free(ifo->fallback);
ifo->fallback = strdup(arg);
if (ifo->fallback == NULL) {
break;
#endif
case O_IAID:
+ ARG_REQUIRED;
if (ifname == NULL) {
logger(ctx, LOG_ERR,
"IAID must belong in an interface block");
ifo->options |= DHCPCD_HOSTNAME | DHCPCD_HOSTNAME_SHORT;
break;
case O_DEV:
+ ARG_REQUIRED;
#ifdef PLUGIN_DEV
if (ctx->dev_load)
free(ctx->dev_load);
}
/* FALLTHROUGH */
case O_ENCAP:
+ ARG_REQUIRED;
if (dop == NULL) {
if (*ldop == NULL) {
logger(ctx, LOG_ERR, "encap must be after a define");
}
break;
case O_VENDCLASS:
+ ARG_REQUIRED;
fp = strwhite(arg);
if (fp)
*fp++ = '\0';
vivco->data = (uint8_t *)np;
break;
case O_AUTHPROTOCOL:
+ ARG_REQUIRED;
fp = strwhite(arg);
if (fp)
*fp++ = '\0';
ifo->auth.options |= DHCPCD_AUTH_SEND;
break;
case O_AUTHTOKEN:
+ ARG_REQUIRED;
fp = strwhite(arg);
if (fp == NULL) {
logger(ctx, LOG_ERR, "authtoken requires a realm");
ifo->options &= ~DHCPCD_DHCP6;
break;
case O_CONTROLGRP:
+ ARG_REQUIRED;
#ifdef _REENTRANT
l = sysconf(_SC_GETGR_R_SIZE_MAX);
if (l == -1)
ifo->options &= ~DHCPCD_IF_UP;
break;
case O_SLAAC:
+ ARG_REQUIRED;
if (strcmp(arg, "private") == 0 ||
strcmp(arg, "stableprivate") == 0 ||
strcmp(arg, "stable") == 0)
}
return 1;
+
+#ifdef ARG_REQUIRED
+arg_required:
+ logger(ctx, LOG_ERR, "option %d requires an argument", opt);
+ return -1;
+#undef ARG_REQUIRED
+#endif
}
static int