]> the.earth.li Git - onak.git/commitdiff
Be more robust when handling unexpected lack of data
authorJonathan McDowell <noodles@earth.li>
Mon, 22 Aug 2016 16:32:37 +0000 (17:32 +0100)
committerJonathan McDowell <noodles@earth.li>
Mon, 22 Aug 2016 16:32:37 +0000 (17:32 +0100)
Make sure we don't assume packets have data (though they should), or
that a key has any uids. Found using American Fuzzy Lop.

keyid.c
wordlist.c

diff --git a/keyid.c b/keyid.c
index 5db10f6d9c03b1aa10dc652e63cc2d1ef5cc8c70..a68513af81e822cdc74f94d5346a080104b367cb 100644 (file)
--- a/keyid.c
+++ b/keyid.c
@@ -145,7 +145,7 @@ onak_status_t get_packetid(struct openpgp_packet *packet, uint64_t *keyid)
        uint8_t         data;
 #endif
 
-       if (packet == NULL)
+       if (packet == NULL || packet->data == NULL)
                return ONAK_E_INVALID_PARAM;
 
        switch (packet->data[0]) {
index 605ec06967752a4209be7591c966d2209f6618d3..b594253951d95ba7ace86347c7fca7d4cbb493df 100644 (file)
@@ -97,7 +97,7 @@ struct ll *makewordlistfromkey(struct ll *wordlist,
        struct ll  *wl = NULL;
 
        uids = keyuids(key, NULL);
-       for (i = 0; uids[i] != NULL; ++i) {
+       for (i = 0; uids != NULL && uids[i] != NULL; ++i) {
                words = makewordlist(NULL, uids[i]);
                for (wl = words; wl != NULL; wl = wl->next) {
                        if (llfind(wordlist, wl->object,