]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Ensure we have options before calling getopt_long(3).
authorRoy Marples <roy@marples.name>
Thu, 6 Jun 2013 18:15:33 +0000 (18:15 +0000)
committerRoy Marples <roy@marples.name>
Thu, 6 Jun 2013 18:15:33 +0000 (18:15 +0000)
if-options.c

index 509a93601dbaf577796df34b03d25227efee6c3e..e4290df053bc15015fb5d8e1118447b1d1cabc02 100644 (file)
@@ -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);