From: Roy Marples Date: Thu, 6 Jun 2013 18:15:33 +0000 (+0000) Subject: Ensure we have options before calling getopt_long(3). X-Git-Tag: v6.0.0~42 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=29c0fd6f454dbf37f0cb197ed9b2a8b695d18880;p=thirdparty%2Fdhcpcd.git Ensure we have options before calling getopt_long(3). --- diff --git a/if-options.c b/if-options.c index 509a9360..e4290df0 100644 --- a/if-options.c +++ b/if-options.c @@ -1231,9 +1231,13 @@ read_config(const char *file, int add_options(struct if_options *ifo, int argc, char **argv) { - int oi, opt, r = 1; + int oi, opt, r; + + if (argc == 0) + return 1; optind = 0; + r = 1; while ((opt = getopt_long(argc, argv, IF_OPTS, cf_options, &oi)) != -1) { r = parse_option(ifo, opt, optarg);