Fix warnings in vlserver/vlprocs.c
authorRuss Allbery <rra@stanford.edu>
Tue, 21 Jul 2009 18:04:41 +0000 (11:04 -0700)
committerDerrick Brashear <shadow@dementia.org>
Thu, 23 Jul 2009 17:43:37 +0000 (10:43 -0700)
rxinfo's code to print out the principal corresponding to an rx_call uses
static arrays for the principal components but was checking that the array
pointer was non-NULL when deciding whether to print principal components.
Instead check whether each portion of the principal is the empty string.

Add explicit initializations of the static buffers to the empty string so
that we're not relying on rxkad_GetServerInfo always initializing them for
us.

Reviewed-on: http://gerrit.openafs.org/http://gerrit.openafs.org/163
Reviewed-by: Simon Wilkinson <sxw@inf.ed.ac.uk>
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>

src/vlserver/vlprocs.c

index 5a5dc1b..73f5658 100644 (file)
@@ -95,9 +95,9 @@ rxinfo(struct rx_call *rxcall)
 {
     int code;
     register struct rx_connection *tconn;
-    char tname[64];
-    char tinst[64];
-    char tcell[64];
+    char tname[64] = "";
+    char tinst[64] = "";
+    char tcell[64] = "";
     afs_uint32 exp;
     struct in_addr hostAddr;
 
@@ -108,7 +108,10 @@ rxinfo(struct rx_call *rxcall)
                            NULL);
     if (!code)
        sprintf(rxinfo_str, "%s %s%s%s%s%s", inet_ntoa(hostAddr), tname,
-               tinst?".":"", tinst?tinst:"", tcell?"@":"", tcell?tcell:"");
+               (tinst[0] == '\0') ? "" : ".",
+               (tinst[0] == '\0') ? "" : tinst,
+               (tcell[0] == '\0') ? "" : "@",
+               (tcell[0] == '\0') ? "" : tcell);
     else
        sprintf(rxinfo_str, "%s noauth", inet_ntoa(hostAddr));
     return (rxinfo_str);