tdb2: make sure records with extra padding have a 0 byte.
[ccan] / ccan / tdb2 / free.c
index d2285567eb0efdf56dfd8d96ec0650845ef403e0..e853d97eedce65dc8ae4b52313ac5a12ca2ba80d 100644 (file)
@@ -523,6 +523,15 @@ again:
                        goto unlock_err;
                }
 
+               /* For futureproofing, we put a 0 in any unused space. */
+               if (rec_extra_padding(&rec)) {
+                       ecode = tdb->methods->twrite(tdb, best_off + sizeof(rec)
+                                                    + keylen + datalen, "", 1);
+                       if (ecode != TDB_SUCCESS) {
+                               goto unlock_err;
+                       }
+               }
+
                /* Bucket of leftover will be <= current bucket, so nested
                 * locking is allowed. */
                if (leftover) {