viced: do not overwrite possible failure
authorMarcio Barbosa <mbarbosa@sinenomine.net>
Thu, 24 Dec 2015 20:23:23 +0000 (17:23 -0300)
committerBenjamin Kaduk <kaduk@mit.edu>
Thu, 24 Dec 2015 23:22:23 +0000 (18:22 -0500)
The function ‘hpr_Initialize’ overwrites the code
returned by ‘ubik_ClientInit’. As a result, ‘hpr_Initialize’
will not report any failure triggered by ‘ubik_ClientInit’.

To fix this problem, store the code returned by ‘rxs_Release’
in a new variable. Only return this code if the function
‘ubik_ClientInit’ worked properly. Otherwise, return the code
provided by ‘ubik_ClientInit’.

Change-Id: I1820e3cbc2131daace01cec0464e56fd2982a783
Reviewed-on: http://gerrit.openafs.org/12137
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/viced/host.c

index 6c54cdc..e44bdb0 100644 (file)
@@ -256,7 +256,7 @@ FreeHT(struct host *entry)
 afs_int32
 hpr_Initialize(struct ubik_client **uclient)
 {
-    afs_int32 code;
+    afs_int32 code, code2;
     struct rx_connection *serverconns[MAXSERVERS];
     struct rx_securityClass *sc;
     struct afsconf_dir *tdir;
@@ -323,7 +323,11 @@ hpr_Initialize(struct ubik_client **uclient)
        ViceLog(0, ("hpr_Initialize: ubik client init failed. [%d]\n", code));
     }
     afsconf_Close(tdir);
-    code = rxs_Release(sc);
+    code2 = rxs_Release(sc);
+
+    if (code == 0) {
+       code = code2;
+    }
     return code;
 }