aboutsummaryrefslogtreecommitdiffstats
path: root/g10/tdbio.c
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2016-08-10 14:41:22 +0000
committerJustus Winter <[email protected]>2016-08-10 14:50:29 +0000
commita27410a251cd25ca96cd6743969c4db0a0fd553f (patch)
treed95d648babaaf0cd93878cc98435d5b6aec8bca7 /g10/tdbio.c
parenttests: Fix distcheck. (diff)
downloadgnupg-a27410a251cd25ca96cd6743969c4db0a0fd553f.tar.gz
gnupg-a27410a251cd25ca96cd6743969c4db0a0fd553f.zip
g10: Fix opening of trust database.
* g10/tdbio.c (tdbio_set_dbname): This function explicitly checks for the file size, but handled the case of a zero-sized file incorrectly by returning success. Fix this by initializing the database in that case. * tests/openpgp/Makefile.am (XTESTS): Add new test. * tests/openpgp/issue2417.scm: New file. GnuPG-bug-id: 2417 Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'g10/tdbio.c')
-rw-r--r--g10/tdbio.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/g10/tdbio.c b/g10/tdbio.c
index e27788e84..02fa91e66 100644
--- a/g10/tdbio.c
+++ b/g10/tdbio.c
@@ -685,7 +685,7 @@ tdbio_set_dbname (const char *new_dbname, int create, int *r_nofile)
take_write_lock ();
- if (access (fname, R_OK))
+ if (access (fname, R_OK) || stat (fname, &statbuf) || statbuf.st_size == 0)
{
FILE *fp;
TRUSTREC rec;
@@ -699,7 +699,7 @@ tdbio_set_dbname (const char *new_dbname, int create, int *r_nofile)
else
gpg_err_set_errno (EIO);
#endif /*HAVE_W32CE_SYSTEM*/
- if (errno != ENOENT)
+ if (errno && errno != ENOENT)
log_fatal ( _("can't access '%s': %s\n"), fname, strerror (errno));
oldmask = umask (077);