From patchwork Fri Feb 27 05:43:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 5897871 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C33ED9F269 for ; Fri, 27 Feb 2015 05:43:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E1D45201FA for ; Fri, 27 Feb 2015 05:43:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1CBD5201F4 for ; Fri, 27 Feb 2015 05:43:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754411AbbB0FnQ (ORCPT ); Fri, 27 Feb 2015 00:43:16 -0500 Received: from smtprelay0213.hostedemail.com ([216.40.44.213]:52127 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751034AbbB0FnP (ORCPT ); Fri, 27 Feb 2015 00:43:15 -0500 Received: from filter.hostedemail.com (unknown [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id 643BCC2120; Fri, 27 Feb 2015 05:43:14 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2, 0, 0, , d41d8cd98f00b204, joe@perches.com, :::::::::, RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1277:1311:1313:1314:1345:1373:1437:1461:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2731:2828:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3870:3871:3872:4321:4385:5007:6261:10004:10400:10848:11026:11232:11473:11658:11914:12043:12296:12438:12517:12519:12555:13069:13311:13357:13972:14096:14097:14394:21080, 0, RBL:none, CacheIP:none, Bayesian:0.5, 0.5, 0.5, Netcheck:none, DomainCache:0, MSF:not bulk, SPF:fn, MSBL:0, DNSBL:none, Custom_rules:0:0:0 X-HE-Tag: linen80_73722f3cd381a X-Filterd-Recvd-Size: 2453 Received: from joe-X200MA.home (pool-71-103-235-196.lsanca.fios.verizon.net [71.103.235.196]) (Authenticated sender: joe@perches.com) by omf02.hostedemail.com (Postfix) with ESMTPA; Fri, 27 Feb 2015 05:43:13 +0000 (UTC) Message-ID: <1425015791.2690.7.camel@perches.com> Subject: [PATCH net-next] wireless: test sscanf return values From: Joe Perches To: Johannes Berg Cc: "David S. Miller" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, LKML Date: Thu, 26 Feb 2015 21:43:11 -0800 X-Mailer: Evolution 3.12.7-0ubuntu1 Mime-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP At some point, it'd be good to make sscanf use __must_check so make sure the net/ uses of sscanf use the return value. Signed-off-by: Joe Perches --- Compiled, untested. net/mac80211/debugfs.c | 4 ++-- net/wireless/core.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index eeb0bbd..0e44be7 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c @@ -160,9 +160,9 @@ static ssize_t sta_tx_latency_stat_write(struct file *file, tx_latency->n_ranges = n_ranges; for (i = 0; i < n_ranges; i++) { /* setting bin ranges */ token = strsep(&bins, TX_LATENCY_BIN_DELIMTER_S); - sscanf(token, "%d", &tx_latency->ranges[i]); /* bins values should be in ascending order */ - if (prev_bin >= tx_latency->ranges[i]) { + if (sscanf(token, "%d", &tx_latency->ranges[i]) != 1 || + prev_bin >= tx_latency->ranges[i]) { ret = -EINVAL; kfree(tx_latency); goto unlock; diff --git a/net/wireless/core.c b/net/wireless/core.c index 3af0ecf..69a350e 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -95,8 +95,8 @@ static int cfg80211_dev_check_name(struct cfg80211_registered_device *rdev, ASSERT_RTNL(); /* prohibit calling the thing phy%d when %d is not its number */ - sscanf(newname, PHY_NAME "%d%n", &wiphy_idx, &taken); - if (taken == strlen(newname) && wiphy_idx != rdev->wiphy_idx) { + if (sscanf(newname, PHY_NAME "%d%n", &wiphy_idx, &taken) == 1 && + taken == strlen(newname) && wiphy_idx != rdev->wiphy_idx) { /* count number of places needed to print wiphy_idx */ digits = 1; while (wiphy_idx /= 10)