From: Jonathan McDowell Date: Mon, 21 Jun 2004 22:19:45 +0000 (+0000) Subject: Fix segfault with non existant short key id & keydb_fs. X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/commitdiff_plain/5976b6484c1db0724cf87303c5ddd66e66e725a8?ds=sidebyside 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. --- 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; }