1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

tdb: fix compilation with TDB_TRACE=1

../../lib/tdb/common/tdb.c: In function ‘tdb_trace_record’:
../../lib/tdb/common/tdb.c:1224:22: error: ‘snprintf’ output truncated before the last format character [-Werror=format-truncation=]
 1224 |                 p += snprintf(p, 2, %02x, rec.dptr[i]);
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../lib/tdb/common/tdb.c:1224:22: note: ‘snprintf’ output 3 bytes into a destination of size 2
cc1: all warnings being treated as errors

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Douglas Bagnall 2024-07-10 14:35:28 +12:00 committed by Douglas Bagnall
parent e61f53b656
commit e653b0870f

View File

@ -1208,7 +1208,7 @@ static void tdb_trace_end_ret(struct tdb_context *tdb, int ret)
static void tdb_trace_record(struct tdb_context *tdb, TDB_DATA rec)
{
char msg[20 + rec.dsize*2], *p;
char msg[21 + rec.dsize*2], *p;
unsigned int i;
/* We differentiate zero-length records from non-existent ones. */
@ -1220,8 +1220,11 @@ static void tdb_trace_record(struct tdb_context *tdb, TDB_DATA rec)
/* snprintf here is purely cargo-cult programming. */
p = msg;
p += snprintf(p, sizeof(msg), " %zu:", rec.dsize);
for (i = 0; i < rec.dsize; i++)
p += snprintf(p, 2, "%02x", rec.dptr[i]);
for (i = 0; i < rec.dsize; i++) {
snprintf(p, 3, "%02x", rec.dptr[i]);
p += 2;
}
tdb_trace_write(tdb, msg);
}