From 5976b6484c1db0724cf87303c5ddd66e66e725a8 Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Mon, 21 Jun 2004 22:19:45 +0000 Subject: [PATCH] Fix segfault with non existant short key id & keydb_fs. We'd segfault if we tried to get a non existant short keyid using keydb_fs; fix this. --- keydb_fs.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/keydb_fs.c b/keydb_fs.c index 01101f0..9575785 100644 --- a/keydb_fs.c +++ b/keydb_fs.c @@ -448,14 +448,16 @@ uint64_t getfullkeyid(uint64_t keyid) keydir(buffer, keyid); d = opendir(buffer); - do { - de = readdir(d); - if (de) - if (de && de->d_name[0] != '.') { - ret = strtoull(de->d_name, NULL, 16); - } - } while (de && de->d_name[0] == '.'); - closedir(d); + if (d) { + do { + de = readdir(d); + if (de) + if (de && de->d_name[0] != '.') { + ret = strtoull(de->d_name, NULL, 16); + } + } while (de && de->d_name[0] == '.'); + closedir(d); + } return ret; } -- 2.39.5