From 2f6509fce7ee20e2d43be6019f43bd47342eccb3 Mon Sep 17 00:00:00 2001 From: Nachiket Kukade Date: Tue, 13 Jun 2017 17:45:46 +0530 Subject: [PATCH] qcacld-3.0: Add maximum bound check on WPA RSN IE length WPA RSN IE is copied from source without a check on the given IE length. A malicious IE length can cause buffer overflow. Add maximum bound check on WPA RSN IE length. Change-Id: Id159d307e8f9c1de720d4553a7c29f23cbd28571 CRs-Fixed: 2052791 --- core/hdd/src/wlan_hdd_cfg80211.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 676d2b1646d1..b48949c23ed4 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -14480,6 +14480,12 @@ static int wlan_hdd_cfg80211_set_ie(hdd_adapter_t *pAdapter, const uint8_t *ie, pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) { + if (eLen > (MAX_WPA_RSN_IE_LEN - 2)) { + hdd_err("%s: Invalid WPA IE length[%d]", + __func__, eLen); + QDF_ASSERT(0); + return -EINVAL; + } hdd_debug("Set WPA IE (len %d)", eLen + 2); memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN);