/*
out of bounds check during a transaction
*/
-static int transaction1_oob(struct tdb_context *tdb, tdb1_off_t len, int probe)
+static int transaction1_oob(struct tdb_context *tdb, tdb1_off_t off, tdb1_off_t len, int probe)
{
- if (len <= tdb->file->map_size) {
+ if (off + len >= off && off + len <= tdb->file->map_size) {
return 0;
}
tdb->last_error = TDB_ERR_IO;
/* make sure we know about any file expansions already done by
anyone else */
- tdb->tdb1.io->tdb1_oob(tdb, tdb->file->map_size + 1, 1);
+ tdb->tdb1.io->tdb1_oob(tdb, tdb->file->map_size, 1, 1);
tdb->tdb1.transaction->old_map_size = tdb->file->map_size;
/* finally hook the io methods, replacing them with
*recovery_size = tdb1_recovery_size(tdb);
/* round up to a multiple of page size */
- *recovery_max_size = TDB1_ALIGN(sizeof(rec) + *recovery_size,
- tdb->tdb1.page_size) - sizeof(rec);
+ *recovery_max_size = tdb1_expand_adjust(tdb->file->map_size,
+ *recovery_size,
+ tdb->tdb1.page_size)
+ - sizeof(rec);
+
*recovery_offset = tdb->file->map_size;
recovery_head = *recovery_offset;
tdb->stats.transaction_expand_file++;
/* remap the file (if using mmap) */
- methods->tdb1_oob(tdb, tdb->file->map_size + 1, 1);
+ methods->tdb1_oob(tdb, tdb->file->map_size, 1, 1);
/* we have to reset the old map size so that we don't try to expand the file
again in the transaction commit, which would destroy the recovery area */
}
tdb->stats.transaction_expand_file++;
tdb->file->map_size = tdb->tdb1.transaction->old_map_size;
- methods->tdb1_oob(tdb, tdb->file->map_size + 1, 1);
+ methods->tdb1_oob(tdb, tdb->file->map_size, 1, 1);
}
/* Keep the open lock until the actual commit */