From: Jim McDonough Date: Thu, 21 May 2009 20:26:26 +0000 (-0400) Subject: Detect tight loop in tdb_find() X-Git-Tag: tdb-1.1.5~431 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a91bcbccf8a2243dac57cacec6fdfc9907580f69;p=thirdparty%2Fsamba.git Detect tight loop in tdb_find() --- diff --git a/lib/tdb/common/tdb.c b/lib/tdb/common/tdb.c index 8c61ec1a89d..b59bb1571c3 100644 --- a/lib/tdb/common/tdb.c +++ b/lib/tdb/common/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);