aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2021-08-12 14:34:10 +0300
committerSergey Poznyakoff <gray@gnu.org>2021-08-12 14:34:10 +0300
commita5cf8700b6b69d5b9a389a98bfa2abbcd76388f7 (patch)
tree60e64f081807353d7fa3febf5fb0d57ed85bc4d2 /src
parent0455af7cfa6dc8a285a9d4140e8cca0af9c41acd (diff)
downloadgdbm-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.c1
-rw-r--r--src/var.c10
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
diff --git a/src/var.c b/src/var.c
index 2772eb1..7b583e2 100644
--- a/src/var.c
+++ b/src/var.c
@@ -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;
}

Return to:

Send suggestions and report system problems to the System administrator.