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

There were no range checks in the original code so the user could
write past the end of the array.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Dan Carpenter 2011-10-20 09:10:09 +03:00 коммит произвёл Greg Kroah-Hartman
Родитель 0d3eb2b29f
Коммит 0c849b3c16
1 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -82,6 +82,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);
@ -168,6 +170,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) {
@ -490,6 +494,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);