]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb/tdb.c
Import from SAMBA's tdb:
[ccan] / ccan / tdb / tdb.c
index 82ad6058032066b95e91b844431407b4a53de64b..42d2438b08be960838733f24bd422f6fdbcaad19 100644 (file)
@@ -96,6 +96,11 @@ static tdb_off_t tdb_find(struct tdb_context *tdb, TDB_DATA key, uint32_t hash,
                                      NULL) == 0) {
                        return rec_ptr;
                }
+               /* detect tight infinite loop */
+               if (rec_ptr == r->next) {
+                       TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_find: loop detected.\n"));
+                       return TDB_ERRCODE(TDB_ERR_CORRUPT, 0);
+               }
                rec_ptr = r->next;
        }
        return TDB_ERRCODE(TDB_ERR_NOEXIST, 0);