]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
readgroup: Make sure user supplies a groupfile
authorSimon Wilkinson <sxw@your-file-system.com>
Sat, 2 Mar 2013 11:44:02 +0000 (11:44 +0000)
committerStephan Wiesand <stephan.wiesand@desy.de>
Tue, 3 Jun 2014 16:47:00 +0000 (12:47 -0400)
If the user supplies enough command line arguments, but doesn't
provide a groupfile, then we can end up trying to open whatever
garbage is on the stack.

Once we've finished parsing the command line arguments, make sure
that a filename was supplied.

Caught by coverity (#986008)

Reviewed-on: http://gerrit.openafs.org/9440
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
(cherry picked from commit 3c564444cf1c0bad25792b10edc158030e180369)

Change-Id: I8d0bb6ec6a39ad095959ede0252dc6f00777515e
Reviewed-on: http://gerrit.openafs.org/11051
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/ptserver/readgroup.c

index 2404fc91d7c661d34ee83ba10b570a9da98b4ed3..b5af337051071f07152c86801473b732646b9af5 100644 (file)
@@ -74,6 +74,8 @@ main(int argc, char **argv)
     afs_int32 i;
     afs_int32 fail = 0;
 
+    buf[0] = '\0';
+
     if (argc < 2) {
        fprintf(stderr, "Usage: readgroup [-v] [-c cellname] groupfile.\n");
        exit(0);
@@ -90,6 +92,13 @@ main(int argc, char **argv)
                strncpy(buf, argv[i], 150);
        }
     }
+
+    /* Catch missing filename */
+    if (buf[0] == '\0') {
+       fprintf(stderr, "Usage: readgroup [-v] [-c cellname] groupfile.\n");
+       exit(0);
+    }
+
     code = pr_Initialize(2, AFSDIR_CLIENT_ETC_DIRPATH, cellname);
     free(cellname);
     if (code) {