From 72879375e37b8bbbd89fc641ddc102de804b3e1b Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Mon, 22 Aug 2016 17:32:37 +0100 Subject: [PATCH] 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. --- keyid.c | 2 +- wordlist.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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, -- 2.39.2