]> git.sommitrealweird.co.uk Git - onak.git/blobdiff - keydb_fs.c
Fix segfault with non existant short key id & keydb_fs.
[onak.git] / keydb_fs.c
index 08aff83f4f2515024950d3388f587ab8f78ceca9..9575785839018e75293448d57b8b16fe28992658 100644 (file)
@@ -347,7 +347,9 @@ static struct ll *internal_get_key_by_word(char *word, struct ll *mct)
                        de = readdir(d);
                        if (de && de->d_name[0] != '.') {
                                if ((!mct)
                        de = readdir(d);
                        if (de && de->d_name[0] != '.') {
                                if ((!mct)
-                                   || (llfind(mct, de->d_name, strcmp) !=
+                                   || (llfind(mct, de->d_name,
+                                       (int (*)(const void *, const void *))
+                                                   strcmp) !=
                                        NULL)) {
                                        logthing(LOGTHING_CRITICAL,
                                                 "Found %s // %s", word,
                                        NULL)) {
                                        logthing(LOGTHING_CRITICAL,
                                                 "Found %s // %s", word,
@@ -446,14 +448,16 @@ uint64_t getfullkeyid(uint64_t keyid)
        keydir(buffer, keyid);
 
        d = opendir(buffer);
        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;
 }
 
        return ret;
 }