1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

tdb: Make tdb_dump_chain circular-list safe

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2018-10-04 15:00:15 +02:00 committed by Jeremy Allison
parent e63f7bd3a9
commit 6502f7a3d2

View File

@ -60,6 +60,7 @@ static tdb_off_t tdb_dump_record(struct tdb_context *tdb, int hash,
static int tdb_dump_chain(struct tdb_context *tdb, int i)
{
struct tdb_chainwalk_ctx chainwalk;
tdb_off_t rec_ptr, top;
if (i == -1) {
@ -74,11 +75,19 @@ static int tdb_dump_chain(struct tdb_context *tdb, int i)
if (tdb_ofs_read(tdb, top, &rec_ptr) == -1)
return tdb_unlock(tdb, i, F_WRLCK);
tdb_chainwalk_init(&chainwalk, rec_ptr);
if (rec_ptr)
printf("hash=%d\n", i);
while (rec_ptr) {
bool ok;
rec_ptr = tdb_dump_record(tdb, i, rec_ptr);
ok = tdb_chainwalk_check(tdb, &chainwalk, rec_ptr);
if (!ok) {
printf("circular hash chain %d\n", i);
break;
}
}
return tdb_unlock(tdb, i, F_WRLCK);