Message ID | 202212231056165052797@zte.com.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp106144wrn; Thu, 22 Dec 2022 18:58:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXv6VvVRut2/06kCgx/w7ITBtjynHeHDyo0faVWrNbXMkO0xyToKhtuLvqHKKumGS6fdHwJ5 X-Received: by 2002:a17:903:3247:b0:189:ec2d:2974 with SMTP id ji7-20020a170903324700b00189ec2d2974mr8694544plb.32.1671764295118; Thu, 22 Dec 2022 18:58:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671764295; cv=none; d=google.com; s=arc-20160816; b=qeH3TG+YX30oSMn+E2bGgnWl3iHkxA2McQn5U9vwXFFAfZOmZNx5GQhaa+x7YxWXi0 gn0eY07DvB4mb5T9OaxIwRdIzzmBL8Gxgg4LcoGsIJSmTyqbFl4yOOrKvJVFprSmeufg RDuSnwwZa3+DfM4NnOsg/g4gHakFTm11pNzmhIwixzlYmtwmeL3EXtS/d+vCpc6LzAj8 mepp6waZnQuBGDER6BxP0zFCnxOJx0XsukLsl6SjMl+cTG+MgDO/T9zPC2ngko4cSDGr lMBnhl0Z0xyv7bmlKs8Mr46zOU1qejZap3CnAPY1uPkzpw/jFyzcwN5s2j9jkCDkCVqj 5ggQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=N6fhsteUjt3CcDj40zQAQgTJDVZ3PVDXEq5HDDzTwFo=; b=aglNoUV1vYMAjqpgAfLPaipKvKK2yyPrRJjJrHrrJ/t0eWRY4U15xZ87fRKA2+GTo8 XsQ98UKeWazX3nZVi9E58rwHVo3m01Hi645WL2C407DM6+Xn0kk5McQEuuM6Mw0dOfrg 3HCqVgn3iAu35tUEPVlVOPOWyUf/e/iMwRvlm7HDChvFjOUzVN1fgJzoBmafDnbxP17w hkeylD6KKfqWjEdap4nia60AXy5lhi/bmavcGvBVoRfb6Kdt+tODHg9G4lQNw69APC7S ZHlXlsrVPNK9M6ZnbNvptgDN7Bk6b32Qzr3CxlQS7ftti25W4aPCezj+0M5iIapsH+91 NrDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020a17090301c700b00186a4763532si2307277plh.28.2022.12.22.18.58.02; Thu, 22 Dec 2022 18:58:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235956AbiLWC5D (ORCPT <rfc822;pacteraone@gmail.com> + 99 others); Thu, 22 Dec 2022 21:57:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229587AbiLWC4i (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 22 Dec 2022 21:56:38 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E68C31DD9; Thu, 22 Dec 2022 18:56:26 -0800 (PST) Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4NdWzF4djFz6FK2Q; Fri, 23 Dec 2022 10:56:25 +0800 (CST) Received: from szxlzmapp03.zte.com.cn ([10.5.231.207]) by mse-fl2.zte.com.cn with SMTP id 2BN2uFBW063500; Fri, 23 Dec 2022 10:56:15 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp02[null]) by mapi (Zmail) with MAPI id mid14; Fri, 23 Dec 2022 10:56:16 +0800 (CST) Date: Fri, 23 Dec 2022 10:56:16 +0800 (CST) X-Zmail-TransId: 2b0463a518d0ffffffffbbbb3c8e X-Mailer: Zmail v1.0 Message-ID: <202212231056165052797@zte.com.cn> Mime-Version: 1.0 From: <yang.yang29@zte.com.cn> To: <stas.yakovlev@gmail.com> Cc: <kvalo@kernel.org>, <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>, <linux-wireless@vger.kernel.org>, <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <xu.panda@zte.com.cn>, <yang.yang29@zte.com.cn> Subject: =?utf-8?q?=5BPATCH_net-next=5D_wifi=3A_ipw2200=3A_use_strscpy=28=29?= =?utf-8?q?_to_instead_of_strncpy=28=29?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl2.zte.com.cn 2BN2uFBW063500 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 63A518D9.000 by FangMail milter! X-FangMail-Envelope: 1671764185/4NdWzF4djFz6FK2Q/63A518D9.000/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/<yang.yang29@zte.com.cn> X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63A518D9.000/4NdWzF4djFz6FK2Q X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752971917555132816?= X-GMAIL-MSGID: =?utf-8?q?1752971917555132816?= |
Series |
[net-next] wifi: ipw2200: use strscpy() to instead of strncpy()
|
|
Commit Message
Yang Yang
Dec. 23, 2022, 2:56 a.m. UTC
From: Xu Panda <xu.panda@zte.com.cn> The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL-terminated strings. Signed-off-by: Xu Panda <xu.panda@zte.com.cn> Signed-off-by: Yang Yang <yang.yang29@zte.com> --- drivers/net/wireless/intel/ipw2x00/ipw2200.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Comments
On Fri, 2022-12-23 at 10:56 +0800, yang.yang29@zte.com.cn wrote: > From: Xu Panda <xu.panda@zte.com.cn> > > The implementation of strscpy() is more robust and safer. > That's now the recommended way to copy NUL-terminated strings. > > Signed-off-by: Xu Panda <xu.panda@zte.com.cn> > Signed-off-by: Yang Yang <yang.yang29@zte.com> > --- > drivers/net/wireless/intel/ipw2x00/ipw2200.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2200.c b/drivers/net/wireless/intel/ipw2x00/ipw2200.c > index ca802af8cddc..6656cea496b1 100644 > --- a/drivers/net/wireless/intel/ipw2x00/ipw2200.c > +++ b/drivers/net/wireless/intel/ipw2x00/ipw2200.c > @@ -1483,8 +1483,7 @@ static ssize_t scan_age_store(struct device *d, struct device_attribute *attr, > > IPW_DEBUG_INFO("enter\n"); > > - strncpy(buffer, buf, len); > - buffer[len] = 0; > + strncpy(buffer, buf, len + 1); > Ummm? But anyway - why bother ... ancient drivers, clearly OK code. johannes
> But anyway - why bother ... ancient drivers, clearly OK code.
Thank you, got it, it's useful information. Sorry for to bother and
please ignore this patch.
diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2200.c b/drivers/net/wireless/intel/ipw2x00/ipw2200.c index ca802af8cddc..6656cea496b1 100644 --- a/drivers/net/wireless/intel/ipw2x00/ipw2200.c +++ b/drivers/net/wireless/intel/ipw2x00/ipw2200.c @@ -1483,8 +1483,7 @@ static ssize_t scan_age_store(struct device *d, struct device_attribute *attr, IPW_DEBUG_INFO("enter\n"); - strncpy(buffer, buf, len); - buffer[len] = 0; + strncpy(buffer, buf, len + 1); if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') { p++;