From: Markus Theil Date: Sun, 9 Feb 2020 16:58:56 +0000 (+0100) Subject: iw: scan: fix buffer over-read in print_ies() X-Git-Tag: v5.8~41 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb13b9dfc0f1625280b5d6ed257b4234d6a6bb6d;p=thirdparty%2Fiw.git iw: scan: fix buffer over-read in print_ies() This patch correctly checks, if enough data bytes for parsing IEs are present (-2 in check for type and length). Furthermore, it adds a nullptr and length check to ease future fuzzing. Signed-off-by: Markus Theil Link: https://lore.kernel.org/r/20200209165902.44110-3-markus.theil@tu-ilmenau.de Signed-off-by: Johannes Berg --- diff --git a/scan.c b/scan.c index 94def00..49db7f1 100644 --- a/scan.c +++ b/scan.c @@ -2190,7 +2190,10 @@ void print_ies(unsigned char *ie, int ielen, bool unknown, .ie = ie, .ielen = ielen }; - while (ielen >= 2 && ielen >= ie[1]) { + if (ie == NULL || ielen < 0) + return; + + while (ielen >= 2 && ielen - 2 >= ie[1]) { if (ie[0] < ARRAY_SIZE(ieprinters) && ieprinters[ie[0]].name && ieprinters[ie[0]].flags & BIT(ptype)) {