summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2005-06-16 16:43:23 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:18:16 -0500
commitfcb339c087de567c860cc9e5e92253a642b982a4 (patch)
tree1cce399d63fe98679bf61a44a18f9d732256c62f
parentc3948492d44cbab2fe132b11bcc4b1b8de410c78 (diff)
downloadsamba-fcb339c087de567c860cc9e5e92253a642b982a4.tar.gz
samba-fcb339c087de567c860cc9e5e92253a642b982a4.tar.bz2
samba-fcb339c087de567c860cc9e5e92253a642b982a4.zip
r7641: Fix based on work from "Shlomi Yaakobovich" <Shlomi@exanet.com> to catch
loops in corrupted tdb files. Jeremy. (This used to be commit f9f3037d6855259edd56fd5a23d63dbb37f0a751)
-rw-r--r--source4/lib/tdb/common/tdb.c13
1 files changed, 7 insertions, 6 deletions
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" <Shlomi@exanet.com>. */
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;