ubik: do not reuse the offset variable for the sync site address 51/13351/3
authorMichael Meffie <mmeffie@sinenomine.net>
Mon, 1 Oct 2018 15:38:37 +0000 (11:38 -0400)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 5 Oct 2018 14:06:02 +0000 (10:06 -0400)
The ubik SendFile function performs a sanity check of the host address
before proceeding with the file transfer.  Currently this check reuses
the file offset local variable to hold the value of the sync site
address, a 32-bit IPv4 address. Not only is this confusing, but also
causes a signed/unsigned type mismatch when comparing host addresses.
Instead of being so stingy with local variables, declare a new local
variable of the correct type to hold the value of the sync site address.

This separation is also a prerequisite for supporting larger address
types in the future.

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

src/ubik/remote.c

index b131da5..fafce4f 100644 (file)
@@ -477,6 +477,7 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
     int tlen;
     struct rx_peer *tpeer;
     struct rx_connection *tconn;
+    afs_uint32 syncHost = 0;
     afs_uint32 otherHost = 0;
     char hoststr[16];
     char pbuffer[1028];
@@ -503,17 +504,17 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
      * screwup.  Thus, we only object if we're sure we know who the sync site
      * is, and it ain't the guy talking to us.
      */
-    offset = uvote_GetSyncSite();
+    syncHost = uvote_GetSyncSite();
     tconn = rx_ConnectionOf(rxcall);
     tpeer = rx_PeerOf(tconn);
     otherHost = ubikGetPrimaryInterfaceAddr(rx_HostOf(tpeer));
-    if (offset && offset != otherHost) {
+    if (syncHost && syncHost != otherHost) {
        /* we *know* this is the wrong guy */
         char sync_hoststr[16];
        ViceLog(0,
            ("Ubik: Refusing synchronization with server %s since it is not the sync-site (%s).\n",
             afs_inet_ntoa_r(otherHost, hoststr),
-            afs_inet_ntoa_r(offset, sync_hoststr)));
+            afs_inet_ntoa_r(syncHost, sync_hoststr)));
        return USYNC;
     }