From: Volker Lendecke Date: Sun, 4 Mar 2018 10:09:10 +0000 (+0100) Subject: tdb: Make sure the hash size fits X-Git-Tag: talloc-2.1.13~293 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5f24fd6863f1278f1e5ea27829c5402c0cae4366;p=thirdparty%2Fsamba.git tdb: Make sure the hash size fits Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c index cfb476d2385..8baa7e40de0 100644 --- a/lib/tdb/common/open.c +++ b/lib/tdb/common/open.c @@ -687,6 +687,21 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int td } } + if (tdb->hash_size > UINT32_MAX/4) { + TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_open_ex: " + "hash size %"PRIu32" too large\n", tdb->hash_size)); + errno = EINVAL; + goto fail; + } + + ret = tdb->methods->tdb_oob(tdb, FREELIST_TOP, 4*tdb->hash_size, 1); + if (ret == -1) { + TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_open_ex: " + "hash size %"PRIu32" does not fit\n", tdb->hash_size)); + errno = EINVAL; + goto fail; + } + if (locked) { if (tdb_nest_unlock(tdb, ACTIVE_LOCK, F_WRLCK, false) == -1) { TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: "