[PATCH] Wireless: Make cfg80211_dev_rename() check sscanf return value in net/wireless/core.c

Previous thread: [PATCH] checkpatch: Add check for too short Kconfig descriptions by Andi Kleen on Friday, March 19, 2010 - 7:32 pm. (8 messages)

Next thread: Won £450,000.00 Reply to (fred_brownn2009@hotmail.com) by Jean-Louis Goffin, Prof. on Friday, March 19, 2010 - 10:07 pm. (1 message)
From: wzt.wzt
Date: Friday, March 19, 2010 - 9:53 pm

Make cfg80211_dev_rename() check sscanf return value.

Signed-off-by: Zhitong Wang <zhitong.wangzt@alibaba-inc.com>

---
 net/wireless/core.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/net/wireless/core.c b/net/wireless/core.c
index 80afacd..8e815b4 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -146,7 +146,9 @@ int cfg80211_dev_rename(struct cfg80211_registered_device *rdev,
 	int idx, taken = -1, result, digits;
 
 	/* prohibit calling the thing phy%d when %d is not its number */
-	sscanf(newname, PHY_NAME "%d%n", &idx, &taken);
+	if (sscanf(newname, PHY_NAME "%d%n", &idx, &taken) != 2)
+		return -EINVAL;
+
 	if (taken == strlen(newname) && idx != rdev->idx) {
 		/* count number of places needed to print idx */
 		digits = 1;
-- 
1.6.5.3

--

From: Johannes Berg
Date: Saturday, March 20, 2010 - 12:39 am

Umm, no, your patch breaks it completely. Look at the logic again.

johannes

--

Previous thread: [PATCH] checkpatch: Add check for too short Kconfig descriptions by Andi Kleen on Friday, March 19, 2010 - 7:32 pm. (8 messages)

Next thread: Won £450,000.00 Reply to (fred_brownn2009@hotmail.com) by Jean-Louis Goffin, Prof. on Friday, March 19, 2010 - 10:07 pm. (1 message)