]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-daemon: Hex encode key before logging
authorMartin Schwenke <mschwenke@ddn.com>
Sun, 8 Feb 2026 23:03:04 +0000 (10:03 +1100)
committerVolker Lendecke <vl@samba.org>
Mon, 9 Feb 2026 12:21:08 +0000 (12:21 +0000)
This currently causes binary data to be logged.

Instead, conditionally hex encode the key in a similar style to the
way it is done in dbwrap_ctdb.c:fetch_locked_internal().  In this
case, the key is truncated if the debug level is less than 10.`

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Feb  9 12:21:08 UTC 2026 on atb-devel-224

ctdb/server/ctdb_vacuum.c

index 7ff79ac574506646356a451e6c59256e8aede22c..d896dd289107e8ea4e012139425ebfd64593bf5c 100644 (file)
@@ -362,9 +362,18 @@ static void fetch_record_migrate_callback(struct ctdb_client_call_state *state)
                goto done;
        }
 
-       D_INFO("Vacuum Fetch record, key=%.*s\n",
-              (int)fetch->key.dsize,
-              fetch->key.dptr);
+       if (DEBUGLEVEL >= DBGLVL_INFO) {
+               char *keystr = hex_encode_talloc(
+                       fetch,
+                       (unsigned char *)fetch->key.dptr,
+                       fetch->key.dsize);
+
+               D_INFO(DEBUGLEVEL >= DBGLVL_DEBUG ?
+                      "Vacuum Fetch record, key=%s\n" :
+                      "Vacuum Fetch record, key=%.20s\n",
+                      keystr ? keystr : "<UNKNOWN>");
+               TALLOC_FREE(keystr);
+       }
 
        (void) ctdb_local_schedule_for_deletion(fetch_queue->ctdb_db,
                                                &hdr,