Skip to content

Commit

Permalink
Staging: vt6656: add some range checks before memcpy()
Browse files Browse the repository at this point in the history
We need to verify that we're not writing past the end of the array.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Dan Carpenter authored and Greg Kroah-Hartman committed Oct 23, 2011
1 parent 883aeec commit 44ec5d2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/staging/vt6656/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
}

pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid;
if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)
return -EINVAL;
if (pItemSSID->len != 0) {
memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
Expand Down Expand Up @@ -155,6 +157,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
}

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);
memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
if (sJoinCmd.wBSSType == ADHOC) {
Expand Down Expand Up @@ -476,6 +480,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
}

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);
memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);

Expand Down

0 comments on commit 44ec5d2

Please sign in to comment.