]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/hash.c
tdb2: extra debugging checks
[ccan] / ccan / tdb2 / hash.c
index d3a195a789f5fcdd76a957e8069e03d2eb0176e3..dec7aae554acbd0f21fd10bf44c886ef72aae9ae 100644 (file)
@@ -560,6 +560,14 @@ int next_in_hash(struct tdb_context *tdb, int ltype,
                                                  ltype);
                                return -1;
                        }
+                       if (rec_magic(&rec) != TDB_MAGIC) {
+                               tdb->log(tdb, TDB_DEBUG_FATAL, tdb->log_priv,
+                                        "next_in_hash:"
+                                        " corrupt record at %llu\n",
+                                        (long long)off);
+                               return -1;
+                       }
+
                        kbuf->dsize = rec_key_length(&rec);
 
                        /* They want data as well? */