Diagnose calling compile_et -v without another argument
authorRuss Allbery <rra@stanford.edu>
Sat, 29 Jun 2013 20:52:46 +0000 (13:52 -0700)
committerJeffrey Altman <jaltman@your-file-system.com>
Tue, 2 Jul 2013 22:15:03 +0000 (15:15 -0700)
Output an error message instead of crashing with a segmentation
fault due to a NULL pointer dereference.

Bug found by Mayhem and reported by Alexandre Rebert.

Change-Id: I484f76411ed6899ea9af81256c1d392a84830d16
Reviewed-on: http://gerrit.openafs.org/10024
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

src/comerr/compile_et.c

index 560cc1b..c73433f 100644 (file)
@@ -212,6 +212,12 @@ main(int argc, char **argv)
                got_prefix = arg;
            } else if (strcmp(arg, "v") == 0) {
                arg = *++argv, argc--;
+               if (arg == NULL) {
+                   fprintf(stderr, "%s: -v option requires an argument\n",
+                           whoami);
+                   usage();
+                   exit(1);
+               }
                version = atoi(arg);
                if (version != 1 && version != 2) {
                    fprintf(stderr, "%s: unknown control argument -`%s'\n",