diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2021-08-12 14:34:10 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2021-08-12 14:34:10 +0300 |
commit | a5cf8700b6b69d5b9a389a98bfa2abbcd76388f7 (patch) | |
tree | 60e64f081807353d7fa3febf5fb0d57ed85bc4d2 /src | |
parent | 0455af7cfa6dc8a285a9d4140e8cca0af9c41acd (diff) | |
download | gdbm-a5cf8700b6b69d5b9a389a98bfa2abbcd76388f7.tar.gz gdbm-a5cf8700b6b69d5b9a389a98bfa2abbcd76388f7.tar.bz2 |
Fix NULL dereference in gdbmshell. Undefine "fd" upon closing the database.
Diffstat (limited to 'src')
-rw-r--r-- | src/gdbmshell.c | 1 | ||||
-rw-r--r-- | src/var.c | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/gdbmshell.c b/src/gdbmshell.c index 8a2b07b..62402e1 100644 --- a/src/gdbmshell.c +++ b/src/gdbmshell.c @@ -67,6 +67,7 @@ closedb (void) datum_free (&key_data); datum_free (&return_data); + variable_unset ("fd"); } static int @@ -567,6 +567,8 @@ open_typeconv (struct variable *var, int type, void **retptr) static int format_sethook (struct variable *var, union value *v) { + if (!v) + return VAR_OK; return _gdbm_str2fmt (v->string) == -1 ? VAR_ERR_BADVALUE : VAR_OK; } @@ -584,6 +586,8 @@ format_typeconv (struct variable *var, int type, void **retptr) static int fd_sethook (struct variable *var, union value *v) { + if (!v) + return VAR_OK; if (v->num < 0) return VAR_ERR_BADVALUE; return VAR_OK; @@ -592,6 +596,8 @@ fd_sethook (struct variable *var, union value *v) static int cachesize_sethook (struct variable *var, union value *v) { + if (!v) + return VAR_OK; if (v->num < 0) return VAR_ERR_BADVALUE; return gdbmshell_setopt ("GDBM_SETCACHESIZE", GDBM_SETCACHESIZE, v->num) == 0 @@ -601,6 +607,8 @@ cachesize_sethook (struct variable *var, union value *v) static int centfree_sethook (struct variable *var, union value *v) { + if (!v) + return VAR_OK; return gdbmshell_setopt ("GDBM_SETCENTFREE", GDBM_SETCENTFREE, v->bool) == 0 ? VAR_OK : VAR_ERR_BADVALUE; } @@ -608,6 +616,8 @@ centfree_sethook (struct variable *var, union value *v) static int coalesce_sethook (struct variable *var, union value *v) { + if (!v) + return VAR_OK; return gdbmshell_setopt ("GDBM_SETCOALESCEBLKS", GDBM_SETCOALESCEBLKS, v->bool) == 0 ? VAR_OK : VAR_ERR_BADVALUE; } |