path: root/src/gdbmdelete.c
diff options
authorSergey Poznyakoff <gray@gnu.org>2018-05-26 22:17:10 +0200
committerSergey Poznyakoff <gray@gnu.org>2018-05-27 17:16:03 +0200
commit4011b4ce9a4c4fa505843381d43a1157cf0c782e (patch)
tree3b12f036a9dabd412a0ada3d6e0c07f44a2dfc91 /src/gdbmdelete.c
parentd100aa7a304913fa1692abaa2818418409f3668a (diff)
Additional validation of avail_table.
Verify that avail_table is sorted by size and that each element's size falls within allowed range. * src/bucket.c (gdbm_get_bucket): Fix bucket validation. Validate bucket_avail. (_gdbm_split_bucket): Check return from _gdbm_free. * src/falloc.c (adjust_bucket_avail,_gdbm_free): Return error code. All uses updated. (pop_avail_block): Fix eventual memory leak. Use gdbm_avail_block_validate. * src/gdbmdefs.h (gdbm_avail_table_valid_p): Change signature. * src/gdbmopen.c (gdbm_avail_table_valid_p): Traverse the array verifying address and size of each element. (gdbm_avail_block_validate) (gdbm_bucket_avail_table_validate): New functions. (validate_header): Remove call to gdbm_avail_block_valid_p. Avail_block is validated later, after it's been loaded. Bail out if header->next_block does not equal the file size. (gdbm_fd_open): Validate avail_block. * src/gdbmstore.c (_gdbm_store): Check return from _gdbm_free. Avoid endless loop in case of inconsistent h_table. * src/gdbmtool.c (_gdbm_print_avail_list): Use gdbm_avail_block_validate. * src/proto.h: Update. * tests/gtload.c: Improve error diagnostics.
Diffstat (limited to 'src/gdbmdelete.c')
1 files changed, 2 insertions, 1 deletions
diff --git a/src/gdbmdelete.c b/src/gdbmdelete.c
index a71ab2c..5660d3a 100644
--- a/src/gdbmdelete.c
+++ b/src/gdbmdelete.c
@@ -82,7 +82,8 @@ gdbm_delete (GDBM_FILE dbf, datum key)
/* Free the file space. */
free_adr = elem.data_pointer;
free_size = elem.key_size + elem.data_size;
- _gdbm_free (dbf, free_adr, free_size);
+ if (_gdbm_free (dbf, free_adr, free_size))
+ return -1;
/* Set the flags. */
dbf->bucket_changed = TRUE;

Return to:

Send suggestions and report system problems to the System administrator.