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) (side-by-side diff)
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
@@ -140,13 +140,16 @@ _gdbm_get_bucket (GDBM_FILE dbf, int dir_index)
dbf->need_recovery = TRUE;
_gdbm_fatal (dbf, gdbm_db_strerror (dbf));
return -1;
}
/* Validate the bucket */
bucket = dbf->bucket_cache[lru].ca_bucket;
- if (!(bucket->count >= 0 && bucket->count <= dbf->header->bucket_elems))
+ if (!(bucket->count >= 0
+ && bucket->count <= dbf->header->bucket_elems
+ && bucket->bucket_bits >= 0
+ && bucket->bucket_bits <= GDBM_HASH_BITS))
{
GDBM_SET_ERRNO (dbf, GDBM_BAD_BUCKET, TRUE);
return -1;
}
/* Validate bucket_avail table */
if (gdbm_bucket_avail_table_validate (dbf, bucket))
diff --git a/src/gdbmtool.c b/src/gdbmtool.c
index dbb7510..6d56578 100644
--- a/src/gdbmtool.c
+++ b/src/gdbmtool.c
@@ -297,13 +297,13 @@ _gdbm_print_avail_list (FILE *fp, GDBM_FILE dbf)
break;
}
/* Print the block! */
fprintf (fp, _("\nblock = %d\nsize = %d\ncount = %d\n"), temp,
av_stk->size, av_stk->count);
- if (gdbm_avail_block_validate (dbf, av_stk))
+ if (gdbm_avail_block_validate (dbf, av_stk) == 0)
av_table_display (av_stk->av_table, av_stk->count, fp);
else
terror (_("invalid avail_block"));
temp = av_stk->next_block;
}
free (av_stk);

Return to:

Send suggestions and report system problems to the System administrator.