ldb_tdb: Move constants into ldb_tdb.h
authorAndrew Bartlett <abartlet@samba.org>
Fri, 1 Sep 2017 08:04:43 +0000 (20:04 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 22 Sep 2017 19:20:20 +0000 (21:20 +0200)
This helps ensure we keep these all in sync.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
lib/ldb/ldb_tdb/ldb_tdb.c
lib/ldb/ldb_tdb/ldb_tdb.h

index 287295a007f8599d1884f468cb1daa2beb518aa5..32d9e344d626fd3ee1da998789b9d84389913fd5 100644 (file)
@@ -156,11 +156,12 @@ bool ltdb_key_is_record(TDB_DATA key)
                return true;
        }
 
-       if (key.dsize < 6) {
+       if (key.dsize < sizeof(LTDB_GUID_KEY_PREFIX)) {
                return false;
        }
 
-       if (memcmp(key.dptr, "GUID=", 5) == 0) {
+       if (memcmp(key.dptr, LTDB_GUID_KEY_PREFIX,
+                  sizeof(LTDB_GUID_KEY_PREFIX) - 1) == 0) {
                return true;
        }
        
index 63620a99ad6da5ecdf0da5c0edb537b5c70f8bb3..8d6c9f500c20b36b2f8b07d4bdddd4ae1611d67e 100644 (file)
@@ -73,6 +73,10 @@ struct ltdb_context {
 #define LTDB_MOD_TIMESTAMP "whenChanged"
 #define LTDB_OBJECTCLASS "objectClass"
 
+/* DB keys */
+#define LTDB_GUID_KEY_PREFIX "GUID="
+#define LTDB_GUID_SIZE 16
+
 /* The following definitions come from lib/ldb/ldb_tdb/ldb_cache.c  */
 
 int ltdb_cache_reload(struct ldb_module *module);