When probing for a size change (eg. just before tdb_expand, tdb_check,
tdb_rescue) we call tdb_oob(tdb, tdb->map_size, 1, 1). Unfortunately
this does nothing if the tdb has actually shrunk, which as Volker
demonstrated, can actually happen if a "longlived" parent crashes.
So move the map/update size/remap before the limit check.
(cherry picked from commit
e7e86fcb929e7b8e7d879349d5f7f9422126a3a2)
return -1;
}
+ /* Unmap, update size, remap */
+ if (tdb_munmap(tdb) == -1) {
+ tdb->ecode = TDB_ERR_IO;
+ return -1;
+ }
+ tdb->map_size = st.st_size;
+ tdb_mmap(tdb);
+
if (st.st_size < (size_t)len) {
if (!probe) {
/* Ensure ecode is set for log fn. */
return -1;
}
- /* Unmap, update size, remap */
- if (tdb_munmap(tdb) == -1) {
- tdb->ecode = TDB_ERR_IO;
- return -1;
- }
- tdb->map_size = st.st_size;
- tdb_mmap(tdb);
return 0;
}