From: Rusty Russell Date: Sat, 28 Aug 2010 11:05:39 +0000 (+0930) Subject: tdb2: check that records are of sufficient length in tdb_check. X-Git-Url: https://git.ozlabs.org/?a=commitdiff_plain;h=b350cb69072fa8647d1e9114188e52b84fba7257;p=ccan-lca-2011.git tdb2: check that records are of sufficient length in tdb_check. --- diff --git a/ccan/tdb2/check.c b/ccan/tdb2/check.c index f8abfc1..42f7538 100644 --- a/ccan/tdb2/check.c +++ b/ccan/tdb2/check.c @@ -372,6 +372,14 @@ int tdb_check(struct tdb_context *tdb, if (tdb->methods->oob(tdb, off + len, false)) goto fail; + if (len < sizeof(p->f)) { + tdb->log(tdb, TDB_DEBUG_ERROR, tdb->log_priv, + "tdb_check: too short record %llu at" + " %llu\n", + (long long)len, (long long)off); + goto fail; + } + if (off + sizeof(p->u) == tdb->header.v.hash_off) { hash_found = true; } else if (off + sizeof(p->u)