Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp5547537rwb; Tue, 17 Jan 2023 15:32:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXsq5h8+lRkjUvcctZFhzib0afixAGvzpf87vOS0YeoyXGKJiTMd2jQinEi9/PdGQDyf0YDa X-Received: by 2002:a05:6a20:42a0:b0:ad:e914:5523 with SMTP id o32-20020a056a2042a000b000ade9145523mr6195262pzj.53.1673998352937; Tue, 17 Jan 2023 15:32:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673998352; cv=none; d=google.com; s=arc-20160816; b=isNXif78RLddyDOQ6t9Os5IUPtoq7Hv6J2ux0HLG7COX0a5uwl8KBPbcBPdluXn/9/ MBfy4vEv0KQlvXyFryQAkOgJA2Dmvaf0cZ/RKT7wsRCjgnTxOpo+zuGoiPr/CHBzCGS4 J3KzW3S+2XU8W+45DOJlLKliuZDZsZLTvWlSp0ENg7GnAJ20uGgO/EC05JcMeVZVszQ4 Xpv5mr6WdDbmAeZiH7hZ1p8SBEtXNks446BxPf1a3wK2w8wHWoz0Z9x1sFNTregSxfvm gtI5FW3yfF1gc/PV8iuV6NKq/NgzSETGHv3+dya5p+/I6xVKMIcHB7lKD62ercZ6eIfL XekQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=0pP+pN1M5uU+rh2BuIa07VvA0EQmkYWSfKV/yjrljRU=; b=QhhS9ZNKNTqh77mAiE5RyPfRI648ap7rIxDfgaE2a6Ryqk2SutytzVwdofxsxR+FWb EPErj9dyMk4Bl+LF/qQbFhSEpdJzDVXTBbCzJ37xgMFKz3XAUejkHOxyDyumnvduN6wL PL/XLcSS0CSBi/2LLWU2aO4pPgsW+HmbpoCtqx0IOYoK/M90eKFi0g1xkD6272ac9mfL dbEpQH4uRWDTeWhEUWncDKfKpAPeFjzhdezjgKg4hTl533vuYBGVccrl+Kpjl5bKAirJ 9N2BDiTuB5jj9prhB++ptF1pTEwgK/CwwsqpzIbJcEfHC8DKhwsmlFSBNEYaXOTRTbWa 0YPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=yIfEx+dX; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a187-20020a6390c4000000b004cf3e0c89a4si3176556pge.742.2023.01.17.15.32.25; Tue, 17 Jan 2023 15:32:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-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; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=yIfEx+dX; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229996AbjAQX2f (ORCPT + 63 others); Tue, 17 Jan 2023 18:28:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbjAQX1n (ORCPT ); Tue, 17 Jan 2023 18:27:43 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFCF15B474; Tue, 17 Jan 2023 13:28:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=MIME-Version:Content-Transfer-Encoding: Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=0pP+pN1M5uU+rh2BuIa07VvA0EQmkYWSfKV/yjrljRU=; t=1673990894; x=1675200494; b=yIfEx+dXdtMUSaUaWXJ0nyjAMqBqQ4jwhC2bYMGl37FB8N3 0gAed30N1xGlDu8kTtnU5Jas47j9GKE8gALGQXuUm4VxdA2Yby9W+lreC+SA2mTwxf4b7nO+VLIDT 7PVkrLtOdvYPMKyl0WzJB6TV7Uzgxbm221b5i7jNoK+CJYcvx/MgcDprLK/bOT2sdzSiEWMXHVjX4 xYru9cLH55Hp/2ba4vn+0LMR00njs2/kr5W5My2hZUJZOYgGNednjRhhWGnEdNLfA+h1O8LOwMpwn c4+UHnQsvOY9hnyHcedF4XPU00AYjHW1bIxdw0oAwBBP4AeiA28/KMOYq8022W/A==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1pHtUs-004p1v-37; Tue, 17 Jan 2023 22:27:59 +0100 Message-ID: Subject: Re: [PATCH net-next] wifi: airo: use strscpy() to instead of strncpy() From: Johannes Berg To: yang.yang29@zte.com.cn, kvalo@kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, akpm@linux-foundation.org, songmuchun@bytedance.com, brauner@kernel.org, julia.lawall@inria.fr, gustavoars@kernel.org, jason@zx2c4.com, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, xu.panda@zte.com.cn Date: Tue, 17 Jan 2023 22:27:57 +0100 In-Reply-To: <202212231052044562664@zte.com.cn> References: <202212231052044562664@zte.com.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.3 (3.46.3-1.fc37) MIME-Version: 1.0 X-malware-bazaar: not-scanned X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS 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: X-Mailing-List: linux-wireless@vger.kernel.org On Fri, 2022-12-23 at 10:52 +0800, yang.yang29@zte.com.cn wrote: > From: Xu Panda >=20 > The implementation of strscpy() is more robust and safer. > That's now the recommended way to copy NUL-terminated strings. >=20 > Signed-off-by: Xu Panda > Signed-off-by: Yang Yang > --- > drivers/net/wireless/cisco/airo.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) >=20 > diff --git a/drivers/net/wireless/cisco/airo.c b/drivers/net/wireless/cis= co/airo.c > index 7c4cc5f5e1eb..600a64f671ce 100644 > --- a/drivers/net/wireless/cisco/airo.c > +++ b/drivers/net/wireless/cisco/airo.c > @@ -6067,8 +6067,7 @@ static int airo_get_nick(struct net_device *dev, > struct airo_info *local =3D dev->ml_priv; >=20 > readConfigRid(local, 1); > - strncpy(extra, local->config.nodeName, 16); > - extra[16] =3D '\0'; > + strscpy(extra, local->config.nodeName, 17); > dwrq->length =3D strlen(extra); >=20 Again, why bother. But is this even correct/identical behaviour? Wouldn't it potentially read 17 input bytes before forcing NUL- termination? johannes