From fcb339c087de567c860cc9e5e92253a642b982a4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 16 Jun 2005 16:43:23 +0000 Subject: r7641: Fix based on work from "Shlomi Yaakobovich" to catch loops in corrupted tdb files. Jeremy. (This used to be commit f9f3037d6855259edd56fd5a23d63dbb37f0a751) --- source4/lib/tdb/common/tdb.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source4') diff --git a/source4/lib/tdb/common/tdb.c b/source4/lib/tdb/common/tdb.c index e9cbc12b91..44533aad27 100644 --- a/source4/lib/tdb/common/tdb.c +++ b/source4/lib/tdb/common/tdb.c @@ -1295,12 +1295,6 @@ static int tdb_next_lock(TDB_CONTEXT *tdb, struct tdb_traverse_lock *tlock, tdb_off current; if (rec_read(tdb, tlock->off, rec) == -1) goto fail; - if (!TDB_DEAD(rec)) { - /* Woohoo: we found one! */ - if (lock_record(tdb, tlock->off) != 0) - goto fail; - return tlock->off; - } /* Detect infinite loops. From "Shlomi Yaakobovich" . */ if (tlock->off == rec->next) { @@ -1308,6 +1302,13 @@ static int tdb_next_lock(TDB_CONTEXT *tdb, struct tdb_traverse_lock *tlock, goto fail; } + if (!TDB_DEAD(rec)) { + /* Woohoo: we found one! */ + if (lock_record(tdb, tlock->off) != 0) + goto fail; + return tlock->off; + } + /* Try to clean dead ones from old traverses */ current = tlock->off; tlock->off = rec->next; -- cgit