From 255dadd76d5a2101d2c5450741326b67253fa9ea Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 9 Jun 2015 11:31:06 +0200 Subject: [PATCH] dirmngr: Avoid crash due to an empty crls.d/DIR.txt. * dirmngr/crlcache.c (check_dir_version): Avoid segv. -- GnuPG-bug-id: 1842 Debian-bug-id: 776611 --- dirmngr/crlcache.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dirmngr/crlcache.c b/dirmngr/crlcache.c index d10e3ca78..d4c3dcb2a 100644 --- a/dirmngr/crlcache.c +++ b/dirmngr/crlcache.c @@ -479,7 +479,9 @@ check_dir_version (estream_t *fpadr, const char *fname, if (lineerr) return lineerr; - if (strtol (line+2, NULL, 10) != DBDIRVERSION) + /* The !line catches the case of an empty DIR file. We handle this + the same as a non-matching version. */ + if (!line || strtol (line+2, NULL, 10) != DBDIRVERSION) { if (!created && cleanup_on_mismatch) {