]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Fix wfd_dev_info parsing for P2P-DEVICE-FOUND (CID 68127)
authorJouni Malinen <j@w1.fi>
Fri, 13 Jun 2014 12:25:39 +0000 (15:25 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 13 Jun 2014 12:25:39 +0000 (15:25 +0300)
Commit b125c48fce823f28d22ebd68297c5b94366c6aa1 ('P2P: Add wfd_dev_info=
field for device found event') added Wi-Fi Display device info to the
P2P-DEVICE-FOUND events. However, it did not include proper bounds
checking in wifi_display_subelem_hex() and could accept subelements with
invalid length field values. This could result in buffer read overflow
of up to 64 kB and inclusion of heap memory in the local control
interface event and/or process crash due to invalid memory access. Fix
this by checking the validity of the length field before writing a
hexdump of the data.

Signed-off-by: Jouni Malinen <j@w1.fi>
wpa_supplicant/wifi_display.c

index 8435b63a779fa213a31c0a20d2f7e37c818ab92e..f0c43644d2589ae4fd9f89c87eae83ed351a27ec 100644 (file)
@@ -276,6 +276,8 @@ char * wifi_display_subelem_hex(const struct wpabuf *wfd_subelems, u8 id)
 
        while (i + WIFI_DISPLAY_SUBELEM_HEADER_LEN < buflen) {
                elen = WPA_GET_BE16(buf + i + 1);
+               if (i + WIFI_DISPLAY_SUBELEM_HEADER_LEN + elen > buflen)
+                       break; /* truncated subelement */
 
                if (buf[i] == id) {
                        subelem = os_zalloc(2 * elen + 1);