From: Volker Lendecke Date: Thu, 4 Oct 2018 13:00:15 +0000 (+0200) Subject: tdb: Make tdb_dump_chain circular-list safe X-Git-Tag: tdb-1.3.17~1389 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6502f7a3d2ac384adf45b8bfbe47516cfa973c16;p=thirdparty%2Fsamba.git tdb: Make tdb_dump_chain circular-list safe Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/lib/tdb/common/dump.c b/lib/tdb/common/dump.c index 73286b87350..d4e3478469b 100644 --- a/lib/tdb/common/dump.c +++ b/lib/tdb/common/dump.c @@ -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);