aboutsummaryrefslogtreecommitdiff
path: root/src/gdbmdefs.h
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-05-24 08:09:48 +0300
committerSergey Poznyakoff <gray@gnu.org>2018-05-24 08:09:48 +0300
commit0665bcf0c9cdf756f9d5edc6a638c56602c42065 (patch)
tree590d81a45721edca6b3530e7681d8f0db32af94b /src/gdbmdefs.h
parentce702a1ca5ed9240cd0a70583c4234c34ce81b73 (diff)
downloadgdbm-0665bcf0c9cdf756f9d5edc6a638c56602c42065.tar.gz
gdbm-0665bcf0c9cdf756f9d5edc6a638c56602c42065.tar.bz2
error checking: check for avail_block consistency before using it
* src/gdbmdefs.h (gdbm_avail_block_valid_p): New function. * src/gdbm.h.in (GDBM_BAD_AVAIL): New error code. * src/gdbmerrno.c: Support new error code. * src/falloc.c (pop_avail_block): Validate the avail_block * src/gdbmopen.c (validate_header): Validate the avail_block. * src/gdbmtool.c (_gdbm_avail_list_size) (_gdbm_print_avail_list): Validate the avail_block.
Diffstat (limited to 'src/gdbmdefs.h')
-rw-r--r--src/gdbmdefs.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/gdbmdefs.h b/src/gdbmdefs.h
index bd104e2..5305b0d 100644
--- a/src/gdbmdefs.h
+++ b/src/gdbmdefs.h
@@ -51,6 +51,13 @@ typedef struct
avail_elem av_table[1]; /* The table. Make it look like an array. */
} avail_block;
+/* Return true if avail_block is valid */
+static int inline
+gdbm_avail_block_valid_p (avail_block const *av)
+{
+ return (av->size >= 0 && av->count >= 0 && av->count <= av->size);
+}
+
/* The dbm file header keeps track of the current location of the hash
directory and the free space in the file. */

Return to:

Send suggestions and report system problems to the System administrator.