Skip to contentSkip to conversation

staging: rtl8192e: Replace sprintf with snprintf

PATCH In review Amitoj Kaur Chawla 2 participants 2 messages Feb 19, 2016 – Feb 20, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8192e: Replace sprintf with snprintf

Replace sprintf with snprintf as sprintf does not check for buffer overflow.

---
 drivers/staging/rtl8192e/rtllib_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192e/rtllib_wx.c +1 -1
index 84e6272..1116a88 100644
@@ -602,7 +602,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
 		char tempbuf[100];
 
 		memset(tempbuf, 0x00, 100);
-		sprintf(tempbuf, "%s", module);
+		snprintf(tempbuf, sizeof(tempbuf), "%s", module);
 		request_module("%s", tempbuf);
 		ops = lib80211_get_crypto_ops(alg);
 	}
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 13 lines · Amitoj Kaur Chawla

Replace sprintf with snprintf as sprintf does not check for buffer overflow.

---
 drivers/staging/rtl8192e/rtllib_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192e/rtllib_wx.c +0 -0
index 84e6272..1116a88 100644

drivers/staging/rtl8192e/rtllib_wx.c int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, · line 605

Quoted 5 lines
drivers/staging/rtl8192e/rtllib_wx.c +1 -1
@@ -602,7 +602,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
 		char tempbuf[100];
 
 		memset(tempbuf, 0x00, 100);
-		sprintf(tempbuf, "%s", module);
+		snprintf(tempbuf, sizeof(tempbuf), "%s", module);

But it's impossible to overflow this buffer, so sprintf() is the correct thing here. I can't take this change, sorry.

greg k-h