]> granicus.if.org Git - sudo/commitdiff
Bail with usage() early if argc <= 0.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 6 Feb 2015 16:17:39 +0000 (09:17 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 6 Feb 2015 16:17:39 +0000 (09:17 -0700)
src/parse_args.c

index 0681c5b481fa6b397141feab6ad1bcec697d97f3..49438da8b580b3db3d8ca70b97676d3814645f20 100644 (file)
@@ -180,6 +180,10 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
     int env_size = 32;
     debug_decl(parse_args, SUDO_DEBUG_ARGS)
 
+    /* Is someone trying something funny? */
+    if (argc <= 0)
+       usage(1);
+
     env_add = sudo_emallocarray(env_size, sizeof(char *));
 
     /* Pass progname to plugin so it can call initprogname() */
@@ -379,10 +383,8 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
     }
     env_add[nenv] = NULL;
 
-    if (argc > 0) {
-       argc -= optind;
-       argv += optind;
-    }
+    argc -= optind;
+    argv += optind;
 
     if (!mode) {
        /* Defer -k mode setting until we know whether it is a flag or not */