From: Rusty Russell Date: Wed, 29 Jul 2009 12:51:34 +0000 (+0930) Subject: Import from SAMBA's tdb: X-Git-Url: https://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=8f4a253ce07435870b61687e487df67a2ee7e19d Import from SAMBA's tdb: commit a91bcbccf8a2243dac57cacec6fdfc9907580f69 Author: Jim McDonough Date: Thu May 21 16:26:26 2009 -0400 Detect tight loop in tdb_find() --- diff --git a/ccan/tdb/tdb.c b/ccan/tdb/tdb.c index 82ad6058..42d2438b 100644 --- a/ccan/tdb/tdb.c +++ b/ccan/tdb/tdb.c @@ -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);