mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 19:07:52 +00:00
staging: rtl8712: memory corruption in wpa_set_encryption()
->KeyMaterial is declared as a 16 byte array, but we only ever allocate either 5 or 13 bytes of it. The problem is that we memset() all 16 bytes to zero so we're memsetting past the end of the allocated memory. I fixed this in slightly lazy way, by just allocating 16 bytes. This works but there is a lot more cleanup you could do to this code if you wanted. Which is why this code is in staging. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
eaf0e7966d
commit
aea48157ce
1 changed files with 1 additions and 4 deletions
|
@ -398,12 +398,9 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
|
||||||
wep_key_idx = 0;
|
wep_key_idx = 0;
|
||||||
if (wep_key_len > 0) {
|
if (wep_key_len > 0) {
|
||||||
wep_key_len = wep_key_len <= 5 ? 5 : 13;
|
wep_key_len = wep_key_len <= 5 ? 5 : 13;
|
||||||
pwep = kmalloc((u32)(wep_key_len +
|
pwep = kzalloc(sizeof(*pwep), GFP_ATOMIC);
|
||||||
FIELD_OFFSET(struct NDIS_802_11_WEP,
|
|
||||||
KeyMaterial)), GFP_ATOMIC);
|
|
||||||
if (pwep == NULL)
|
if (pwep == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
memset(pwep, 0, sizeof(struct NDIS_802_11_WEP));
|
|
||||||
pwep->KeyLength = wep_key_len;
|
pwep->KeyLength = wep_key_len;
|
||||||
pwep->Length = wep_key_len +
|
pwep->Length = wep_key_len +
|
||||||
FIELD_OFFSET(struct NDIS_802_11_WEP,
|
FIELD_OFFSET(struct NDIS_802_11_WEP,
|
||||||
|
|
Loading…
Reference in a new issue