r5533: Patch to detect infinite loops when traversing a tdb from "Shlomi Yaakobovich...
authorJeremy Allison <jra@samba.org>
Thu, 24 Feb 2005 01:10:57 +0000 (01:10 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:10:53 +0000 (13:10 -0500)
Jeremy.
(This used to be commit 84f6d2b3dd29c1aa478708db9617a79382158f64)

source4/lib/tdb/common/tdb.c

index 134ee8a4ead59813f9542132dacf5640d324f117..90b586d487b8e2563dec8c9b7b54d2985f6933af 100644 (file)
@@ -1314,6 +1314,13 @@ static int tdb_next_lock(TDB_CONTEXT *tdb, struct tdb_traverse_lock *tlock,
                                        goto fail;
                                return tlock->off;
                        }
+
+                       /* Detect infinite loops. From "Shlomi Yaakobovich" <Shlomi@exanet.com>. */
+                       if (tlock->off == rec->next) {
+                               TDB_LOG((tdb, 0, "tdb_next_lock: loop detected.\n"));
+                               goto fail;
+                       }
+
                        /* Try to clean dead ones from old traverses */
                        current = tlock->off;
                        tlock->off = rec->next;