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

lib tdb: memcmp ubsan warning

Fix the ubsan warning

lib/tdb/common/tdb.c:184:9: runtime error: null pointer passed as
argument 2, which is declared to never be null"

memcmp call now guarded by a length check.

memcmp returns zero when called with a zero length parameter.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Noel Power <npower@samba.org>

Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Mon Jul  1 14:50:54 UTC 2019 on sn-devel-184
This commit is contained in:
Gary Lockyer 2019-06-06 14:57:45 +12:00 committed by Noel Power
parent 2b7236ffe1
commit a77fda0cd4

View File

@ -180,12 +180,14 @@ static int tdb_update_hash_cmp(TDB_DATA key, TDB_DATA data, void *private_data)
for (i=0; i<state->num_dbufs; i++) {
TDB_DATA dbuf = state->dbufs[i];
int ret;
ret = memcmp(dptr, dbuf.dptr, dbuf.dsize);
if (ret != 0) {
return -1;
if( dbuf.dsize > 0) {
int ret;
ret = memcmp(dptr, dbuf.dptr, dbuf.dsize);
if (ret != 0) {
return -1;
}
dptr += dbuf.dsize;
}
dptr += dbuf.dsize;
}
return 0;