]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Move zero argc check earlier in ksu 770/head
authorGreg Hudson <ghudson@mit.edu>
Tue, 24 Apr 2018 23:35:38 +0000 (19:35 -0400)
committerGreg Hudson <ghudson@mit.edu>
Thu, 26 Apr 2018 15:11:09 +0000 (11:11 -0400)
For improved auditability, check for a zero argc value earlier in
main() so that the first two calls to com_err() can't pass a NULL
whoami value--which would be harmless, but that may not be obvious to
a reader.

ticket: 8661

src/clients/ksu/main.c

index 5e79ef5f423a3514452bd06b2af36bb4d512e20b..30f6db771608a9f116d1e020e1745ff6fd3abbbf 100644 (file)
@@ -121,6 +121,9 @@ main (argc, argv)
     krb5_boolean restrict_creds;
     krb5_deltat lifetime, rlife;
 
+    if (argc == 0)
+        exit(1);
+
     params = (char **) xcalloc (2, sizeof (char *));
     params[1] = NULL;
 
@@ -138,8 +141,6 @@ main (argc, argv)
         exit(1);
     }
 
-    if (argc == 0)
-        exit(1);
     if (strrchr(argv[0], '/'))
         argv[0] = strrchr(argv[0], '/')+1;
     prog_name = argv[0];