ldb_tdb: Use memcmp() to compare TDB keys in re_index()
authorAndrew Bartlett <abartlet@samba.org>
Tue, 15 Aug 2017 02:25:59 +0000 (14:25 +1200)
committerKarolin Seeger <kseeger@samba.org>
Thu, 14 Sep 2017 15:48:26 +0000 (17:48 +0200)
The keys may not always be a null terminated string, they could well
be a binary GUID in a future revision, for efficiency..

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13016

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
(cherry picked from commit da1e23418a1d0e6b77dcf24bf6cbbc18b0fe020b)

lib/ldb/ldb_tdb/ldb_index.c

index 232bb4c16d91d6a2e4820c77514e93b1f1586a16..fbc05bd6f1a3f8191fbdb3b945b63feeff43ce17 100644 (file)
@@ -1620,7 +1620,8 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *
                talloc_free(msg);
                return 0;
        }
-       if (strcmp((char *)key2.dptr, (char *)key.dptr) != 0) {
+       if (key.dsize != key2.dsize ||
+           (memcmp(key.dptr, key2.dptr, key.dsize) != 0)) {
                tdb_delete(tdb, key);
                tdb_store(tdb, key2, data, 0);
        }