]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
NFC: Avoid misaligned read of an NDEF field
authorJouni Malinen <j@w1.fi>
Tue, 7 Jul 2015 12:33:55 +0000 (15:33 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 7 Jul 2015 13:25:06 +0000 (16:25 +0300)
The 32-bit version of payload length field may not be 32-bit aligned in
the message buffer, so use WPA_GET_BE32() to read it instead of ntohl().

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

index 8d1ce1eacc34a1bfe52cdd4240c0c95c7ce3c21b..5604b0a5d888a26bdf3647ffb99f3d45e926480a 100644 (file)
@@ -47,7 +47,7 @@ static int ndef_parse_record(const u8 *data, u32 size,
        } else {
                if (size < 6)
                        return -1;
-               record->payload_length = ntohl(*(u32 *)pos);
+               record->payload_length = WPA_GET_BE32(pos);
                pos += sizeof(u32);
        }