libadmin: Don't dereference NULL pointer in cmd
authorSimon Wilkinson <sxw@inf.ed.ac.uk>
Sat, 12 Jun 2010 09:42:43 +0000 (10:42 +0100)
committerDerrick Brashear <shadow@dementia.org>
Sun, 13 Jun 2010 05:41:29 +0000 (22:41 -0700)
If DoBosHostList ends up being called without the -server argument
in its command structure, then a printf will attempt to dereference
a NULL pointer to the -server field.

Caught by clang-analyzer

Change-Id: I1114406d03b265f4d780efd8e84fea53013cb51c
Reviewed-on: http://gerrit.openafs.org/2143
Reviewed-by: Russ Allbery <rra@stanford.edu>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/libadmin/test/bos.c

index 3b283b3..3661d2c 100644 (file)
@@ -1270,13 +1270,14 @@ DoBosHostList(struct cmd_syndesc *as, void *arock)
            (cellHandle, as->parms[SERVER].items->data, &bos_server, &st)) {
            ERR_ST_EXT("bos_ServerOpen", st);
        }
+
+        printf("Listing hosts at server %s\n", as->parms[SERVER].items->data);
     }
 
     if (!bos_HostGetBegin(bos_server, &iter, &st)) {
        ERR_ST_EXT("bos_HostGetBegin", st);
     }
 
-    printf("Listing hosts at server %s\n", as->parms[SERVER].items->data);
 
     while (bos_HostGetNext(iter, host, &st)) {
        printf("\t%s\n", host);