From: Jonathan McDowell Date: Mon, 22 Aug 2016 16:32:37 +0000 (+0100) Subject: Be more robust when handling unexpected lack of data X-Git-Tag: onak-0.5.0~5 X-Git-Url: https://the.earth.li/gitweb/?a=commitdiff_plain;h=72879375e37b8bbbd89fc641ddc102de804b3e1b;p=onak.git Be more robust when handling unexpected lack of data Make sure we don't assume packets have data (though they should), or that a key has any uids. Found using American Fuzzy Lop. --- diff --git a/keyid.c b/keyid.c index 5db10f6..a68513a 100644 --- 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]) { diff --git a/wordlist.c b/wordlist.c index 605ec06..b594253 100644 --- a/wordlist.c +++ b/wordlist.c @@ -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,