aboutsummaryrefslogtreecommitdiff
path: root/src/gdbmexp.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-07-08 11:28:53 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2016-07-08 14:12:34 +0300
commit4aef6b36f862e46723403bc6422ac47058a5ef19 (patch)
treefa7afe6ed8f1abf080fa764bda1bbc81e07f407b /src/gdbmexp.c
parent260102cf7f75db3c87d04a06eb8054853cacce97 (diff)
downloadgdbm-4aef6b36f862e46723403bc6422ac47058a5ef19.tar.gz
gdbm-4aef6b36f862e46723403bc6422ac47058a5ef19.tar.bz2
Fix error handling in gdbm_fetch, gdbm_firstkey, and gdbm_nextkey.
* src/gdbmfetch.c: Hanlde out of memory error. * src/findkey.c: Set gdbm_errno to GDBM_ITEM_NOT_FOUND if nothing was found. * src/gdbmdelete.c: Don't set gdbm_errno after _gdbm_findkey returns -1. It's been done already. * src/gdbmexp.c (gdbm_export_to_file): Return -1 if gdbm_fetch fails. * src/gdbmseq.c (get_next_key): Set gdbm_errno to GDBM_ITEM_NOT_FOUND if there's no next key. Don't call _gdbm_fatal on out of memory condition. (gdbm_nextkey): Set gdbm_errno to GDBM_ITEM_NOT_FOUND if there's no next key. * src/gdbmtool.c (fetch_handler) (firstkey_handler,nextkey_handler): Check gdbm_errno. * src/gdbmstore.c: Handle error return from _gdbm_findkey. * tests/gtdump.c: Likewise. * tests/gtfetch.c: Likewise. * doc/gdbm.texi: Document changes. * doc/gdbm.3: Likewise. * configure.ac: Version 1.12.90 * NEWS: Update. * .gitignore: Update.
Diffstat (limited to 'src/gdbmexp.c')
-rw-r--r--src/gdbmexp.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/gdbmexp.c b/src/gdbmexp.c
index e3babc0..e68457f 100644
--- a/src/gdbmexp.c
+++ b/src/gdbmexp.c
@@ -1,7 +1,7 @@
/* gdbmexp.c - Export a GDBM database. */
/* This file is part of GDBM, the GNU data base manager.
- Copyright (C) 2007, 2011, 2013 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2011, 2013, 2016 Free Software Foundation, Inc.
GDBM is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -46,7 +46,12 @@ gdbm_export_to_file (GDBM_FILE dbf, FILE *fp)
while (key.dptr != NULL)
{
data = gdbm_fetch (dbf, key);
- if (data.dptr != NULL)
+ if (data.dptr == NULL)
+ {
+ if (gdbm_errno != GDBM_NO_ERROR)
+ return -1;
+ }
+ else
{
/* Add the data to the new file. */
size = htonl (key.dsize);
@@ -61,6 +66,7 @@ gdbm_export_to_file (GDBM_FILE dbf, FILE *fp)
if (fwrite (data.dptr, data.dsize, 1, fp) != 1)
goto write_fail;
}
+
nextkey = gdbm_nextkey (dbf, key);
free (key.dptr);
free (data.dptr);
@@ -68,6 +74,8 @@ gdbm_export_to_file (GDBM_FILE dbf, FILE *fp)
count++;
}
+ if (gdbm_errno != GDBM_ITEM_NOT_FOUND)
+ return -1;
return count;

Return to:

Send suggestions and report system problems to the System administrator.