Commit 44ec5d29 authored by Dan Carpenter's avatar Dan Carpenter Committed by Greg Kroah-Hartman

Staging: vt6656: add some range checks before memcpy()

We need to verify that we're not writing past the end of the array.
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 883aeecc
...@@ -81,6 +81,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) ...@@ -81,6 +81,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
} }
pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid; pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid;
if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)
return -EINVAL;
if (pItemSSID->len != 0) { if (pItemSSID->len != 0) {
memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
...@@ -155,6 +157,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) ...@@ -155,6 +157,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
} }
pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid; pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid;
if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)
return -EINVAL;
memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
if (sJoinCmd.wBSSType == ADHOC) { if (sJoinCmd.wBSSType == ADHOC) {
...@@ -476,6 +480,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) ...@@ -476,6 +480,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
} }
pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid; pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid;
if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)
return -EINVAL;
memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN); memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment