ctdb-client: Initialize ctdb_ltdb_header completely for empty record
authorAmitay Isaacs <amitay@gmail.com>
Mon, 11 Sep 2017 04:05:17 +0000 (14:05 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 14 Sep 2017 12:49:15 +0000 (14:49 +0200)
ctdb_ltdb_fetch() only fills in relevant portion of ctdb_ltdb_header
if the record does not exist.  This can result in uninitialized writes
to ctdb_rec_buffer.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/client/client_db.c

index e3eaf7dd1068c6402e06d0b54ae04486be9ac6fe..e86830e7bfb99009e9a7010c347c6b129121107c 100644 (file)
@@ -1116,9 +1116,9 @@ int ctdb_ltdb_fetch(struct ctdb_db_context *db, TDB_DATA key,
                        return EIO;
                }
 
-               header->rsn = 0;
-               header->dmaster = CTDB_UNKNOWN_PNN;
-               header->flags = 0;
+               *header = (struct ctdb_ltdb_header) {
+                       .dmaster = CTDB_UNKNOWN_PNN,
+               };
 
                if (data != NULL) {
                        *data = tdb_null;