]> git.sommitrealweird.co.uk Git - onak.git/commitdiff
Fix segfault with non existant short key id & keydb_fs.
authorJonathan McDowell <noodles@earth.li>
Mon, 21 Jun 2004 22:19:45 +0000 (22:19 +0000)
committerJonathan McDowell <noodles@earth.li>
Mon, 21 Jun 2004 22:19:45 +0000 (22:19 +0000)
We'd segfault if we tried to get a non existant short keyid using keydb_fs;
fix this.

keydb_fs.c

index 01101f0eaeca4683a077e71fbc7ed45c651ce8ca..9575785839018e75293448d57b8b16fe28992658 100644 (file)
@@ -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;
 }