s3:dbwrap_ctdb: fix reading/storing of special key __db_sequence_number__
authorMichael Adam <obnox@samba.org>
Mon, 18 Jan 2010 16:26:04 +0000 (17:26 +0100)
committerKarolin Seeger <kseeger@samba.org>
Thu, 1 Apr 2010 07:39:16 +0000 (09:39 +0200)
The key for reading and writing was inconsistent due to a
off by one data length.

Michael
(cherry picked from commit 1933214108d1a71bc6473a696ce35020a427d8f4)
(cherry picked from commit c17daced42b3ea78fa8e6f6afc8c2550cac53ca0)

source3/lib/dbwrap_ctdb.c

index 79c4c0ce420f0cdd28085999d99ba9ed2ba654d0..ddc886864bec06e9aa5238c452a5e4b4d115f98f 100644 (file)
@@ -688,8 +688,7 @@ static NTSTATUS db_ctdb_fetch_db_seqnum_from_db(struct db_ctdb_ctx *db,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       key.dptr = (uint8_t *)discard_const(keyname);
-       key.dsize = strlen(keyname) + 1;
+       key = string_term_tdb_data(keyname);
 
        status = db_ctdb_ltdb_fetch(db, key, &header, mem_ctx, &data);
        if (!NT_STATUS_IS_OK(status) &&
@@ -723,8 +722,7 @@ static NTSTATUS db_ctdb_store_db_seqnum(struct db_ctdb_transaction_handle *h,
        TDB_DATA key;
        TDB_DATA data;
 
-       key.dptr = (uint8_t *)discard_const(keyname);
-       key.dsize = strlen(keyname);
+       key = string_term_tdb_data(keyname);
 
        data.dptr = (uint8_t *)&seqnum;
        data.dsize = sizeof(uint64_t);