summaryrefslogtreecommitdiffabout
path: root/src
authorSergey Poznyakoff <gray@gnu.org>2018-05-30 12:59:49 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2018-05-30 13:03:58 (GMT)
commit5ea6f531857cb61946456c2582f7eaa20ceba18b (patch) (unidiff)
tree757022d0d2ca32388925ab97c417323363e047a6 /src
parent156f33c8aa5b5c113987c353bbd32c70f02f6a9d (diff)
downloadgdbm-5ea6f531857cb61946456c2582f7eaa20ceba18b.tar.gz
gdbm-5ea6f531857cb61946456c2582f7eaa20ceba18b.tar.bz2
More error checking
* src/bucket.c (_gdbm_get_bucket): Check if bucket_bits value is valid. * src/gdbmtool.c (_gdbm_print_avail_list): Reverse the sense of the conditional (fix regression).
Diffstat (limited to 'src') (more/less context) (ignore whitespace changes)
-rw-r--r--src/bucket.c5
-rw-r--r--src/gdbmtool.c2
2 files changed, 5 insertions, 2 deletions
diff --git a/src/bucket.c b/src/bucket.c
index e17019c..a3e8f4e 100644
--- a/src/bucket.c
+++ b/src/bucket.c
@@ -143,7 +143,10 @@ _gdbm_get_bucket (GDBM_FILE dbf, int dir_index)
143 } 143 }
144 /* Validate the bucket */ 144 /* Validate the bucket */
145 bucket = dbf->bucket_cache[lru].ca_bucket; 145 bucket = dbf->bucket_cache[lru].ca_bucket;
146 if (!(bucket->count >= 0 && bucket->count <= dbf->header->bucket_elems)) 146 if (!(bucket->count >= 0
147 && bucket->count <= dbf->header->bucket_elems
148 && bucket->bucket_bits >= 0
149 && bucket->bucket_bits <= GDBM_HASH_BITS))
147 { 150 {
148 GDBM_SET_ERRNO (dbf, GDBM_BAD_BUCKET, TRUE); 151 GDBM_SET_ERRNO (dbf, GDBM_BAD_BUCKET, TRUE);
149 return -1; 152 return -1;
diff --git a/src/gdbmtool.c b/src/gdbmtool.c
index dbb7510..6d56578 100644
--- a/src/gdbmtool.c
+++ b/src/gdbmtool.c
@@ -300,7 +300,7 @@ _gdbm_print_avail_list (FILE *fp, GDBM_FILE dbf)
300 /* Print the block! */ 300 /* Print the block! */
301 fprintf (fp, _("\nblock = %d\nsize = %d\ncount = %d\n"), temp, 301 fprintf (fp, _("\nblock = %d\nsize = %d\ncount = %d\n"), temp,
302 av_stk->size, av_stk->count); 302 av_stk->size, av_stk->count);
303 if (gdbm_avail_block_validate (dbf, av_stk)) 303 if (gdbm_avail_block_validate (dbf, av_stk) == 0)
304 av_table_display (av_stk->av_table, av_stk->count, fp); 304 av_table_display (av_stk->av_table, av_stk->count, fp);
305 else 305 else
306 terror (_("invalid avail_block")); 306 terror (_("invalid avail_block"));

Return to:

Send suggestions and report system problems to the System administrator.