From eb2280663f086b61b064ba0ca16aff98c5d81ba1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 16 Jun 2005 16:39:49 +0000 Subject: r7640: Fix based on work from "Shlomi Yaakobovich" to catch loops in corrupted tdb files. Jeremy. (This used to be commit b438cb0a85217c978f1d7cb9f2a4fd97f38a3193) --- source3/tdb/tdb.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c index d91e6e4efc..47a2f070b6 100644 --- a/source3/tdb/tdb.c +++ b/source3/tdb/tdb.c @@ -1270,12 +1270,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) { @@ -1283,6 +1277,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