Skip to contentSkip to conversation

staging: rtl8192e: initializing the wep buffer

PATCH In review Kangjie Lu 2 participants 2 messages Oct 18, 2019 Staging

lore
Share & tools
lore

Kangjie Lu

author
#0 lore raw

PATCH 1/1 staging: rtl8192e: initializing the wep buffer

The "wep" buffer is not initialized. To avoid memory disclosures, the fix initializes it, as peer functions like rtllib_ccmp_set_key do.

---
 drivers/staging/rtl8192e/rtllib_crypt_wep.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/rtl8192e/rtllib_crypt_wep.c +1 -0
index b1ea650036d2..0931777ed157 100644
@@ -232,6 +232,7 @@ static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv)
 	if (len < 0 || len > WEP_KEY_LEN)
 		return -1;
 
+	memset(wep, 0, sizeof(*wep));
 	memcpy(wep->key, key, len);
 	wep->key_len = len;
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 14 lines · Kangjie Lu

The "wep" buffer is not initialized. To avoid memory disclosures, the fix initializes it, as peer functions like rtllib_ccmp_set_key do.

---
 drivers/staging/rtl8192e/rtllib_crypt_wep.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/rtl8192e/rtllib_crypt_wep.c +0 -0
index b1ea650036d2..0931777ed157 100644

drivers/staging/rtl8192e/rtllib_crypt_wep.c static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) · line 237

Quoted 6 lines
drivers/staging/rtl8192e/rtllib_crypt_wep.c +1 -0
@@ -232,6 +232,7 @@ static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv)
 	if (len < 0 || len > WEP_KEY_LEN)
 		return -1;
 
+	memset(wep, 0, sizeof(*wep));
 	memcpy(wep->key, key, len);
 	wep->key_len = len;

If we read beyond wep->key_len then it's probably a bug, right? It doesn't matter whether it's zeroed out or not. Fortunately we never do:

	memcpy(key, wep->key, wep->key_len);

So this change isn't required.

regards,
dan carpenter