]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
NFC: Add a hardcoded limit on maximum NDEF payload length
authorJouni Malinen <j@w1.fi>
Wed, 8 Jul 2015 14:00:28 +0000 (17:00 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 8 Jul 2015 14:03:34 +0000 (17:03 +0300)
While this is already enforced in practice due to the limits on the
maximum control interface command length and total_length bounds
checking here, this explicit check on payload_length value may help
static analyzers understand the code better. (CID 122668)

Signed-off-by: Jouni Malinen <j@w1.fi>
src/wps/ndef.c

index 50d018f94d0b03f7c6151640c6e1c5350ddbd080..cc8f6e5cbf65a9383c78bab06210eeaaaeb26ad9 100644 (file)
@@ -48,7 +48,8 @@ static int ndef_parse_record(const u8 *data, u32 size,
                if (size < 6)
                        return -1;
                record->payload_length = WPA_GET_BE32(pos);
-               if (record->payload_length > size - 6)
+               if (record->payload_length > size - 6 ||
+                   record->payload_length > 20000)
                        return -1;
                pos += sizeof(u32);
        }