s3: Slight reshaping of server_exists_parse
authorVolker Lendecke <vl@samba.org>
Sun, 4 Jul 2010 12:35:05 +0000 (14:35 +0200)
committerVolker Lendecke <vl@samba.org>
Sun, 4 Jul 2010 12:37:10 +0000 (14:37 +0200)
Doing a copy and then do the compare is a bit pointless, use memcmp

source3/lib/serverid.c

index 5f97bd310f3c9c59e25cf06cc0bd86a4605a500d..e9c72961e6d1a209e0973ab18e259cac21374173 100644 (file)
@@ -183,10 +183,12 @@ static int server_exists_parse(TDB_DATA key, TDB_DATA data, void *priv)
                return -1;
        }
 
-       /* memcpy, data.dptr might not be aligned */
-       memcpy(&unique_id, data.dptr, sizeof(unique_id));
-
-       state->exists = (state->id->unique_id == unique_id);
+       /*
+        * Use memcmp, not direct compare. data.dptr might not be
+        * aligned.
+        */
+       state->exists =
+               (memcmp(&unique_id, data.dptr, sizeof(unique_id)) == 0);
        return 0;
 }