Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp5547335rwb; Tue, 17 Jan 2023 15:32:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXslPRkD0ezvRbHJsTOY/+6beduF+cu3nNuZO1Q/uKs9ue7PWF5T0mDwl4qR3mjH3F0pCayR X-Received: by 2002:a17:906:248f:b0:86e:8b7b:ad8f with SMTP id e15-20020a170906248f00b0086e8b7bad8fmr4439909ejb.18.1673998340725; Tue, 17 Jan 2023 15:32:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673998340; cv=none; d=google.com; s=arc-20160816; b=zTT1IHRFrBGFfMmpRmqTWUQ6UhlXOCPbTrJujzDDIHnu/LAauOfFbaE6mNIEx6Icx4 B+9Lc1SZ1QuZDL5gUnYRbuLgRS22WItd/STJBOqlEmMv21zr2Y//qAVS6m07L82mtKDO CghLgYXavj2CNU/0FmBZWMprJkLMasvTc+weLw3x1JXXBlcbLsuvEkcOyuPWRqHI3w+J 2w86zkovWgIkqibnYNMpE42+NIRPCtmYXKNOCkXD9lnKOzWXSRITeqeMAlsgKY68CaPG BQ4Wmr9oZ2QcpO7m3pfgX2/qaPE1gAN0qQ9W4PLQB/SqeHZc+6Di8xM49+T/pWv8PwrW QgUA== 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=McmG1jOzMvtt3wWGVUxfmdV8HITDF3CT0GifJJycbDo=; b=S9uQC3ppkH4NpdgLjyyxO8dDwLt28J5L7gABbuRfxF6V5nRV+fFT24CKU3+oC06AEL XUOs9DpBaLhIeG+jVy/dpHxTSv56avTNt7f44eokzNYYz63dnXQW6K2EiQRbW/GcvU+w BVhG/14Mln98FvsawBPU5Qo4r2EulTANPItHJIWPUGH3c3lIZe1DtL+1UZ66oiibCbUT n92EF1eaEtZbdRjHxBS+dLkKro/hn+hPE0D4Dwzm8RR3iFlRM8KHb4BYEH178Nv3A0Ux HZiPLvrH6G/Rf4uRBt8MPsz82cXhAUYvxcwhdiQlDwSr60M0nixzzzJRxUQW3Pi8t1K2 Yjrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=a5A3n4e1; 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 e5-20020a17090658c500b0087305ff8c42si2899128ejs.909.2023.01.17.15.32.01; Tue, 17 Jan 2023 15:32:20 -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=a5A3n4e1; 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 S229790AbjAQX1I (ORCPT + 63 others); Tue, 17 Jan 2023 18:27:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229687AbjAQX0U (ORCPT ); Tue, 17 Jan 2023 18:26:20 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 458C13928B; Tue, 17 Jan 2023 13:23:37 -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=McmG1jOzMvtt3wWGVUxfmdV8HITDF3CT0GifJJycbDo=; t=1673990620; x=1675200220; b=a5A3n4e1neWfxsl2W6TZND28yoyzhnQpQ0Mk8NdmkZW+zOE IoffS3G6g1pd/RODnv9FGQ1vkfn0tZmrDn6TIUtcGTxRsA6vVOrdZg01EgVvl1eH8kSTzmk69kfKg EDSguKCnJOroVj6aM6oTl+Y7aS3eBzaW9WmF9Jq5lZ1Iqx1DJAg8JtCK+wC4sIfB9zlRIXZXhJOD2 hLXqBCkVuBfqlPoswgNdWYl24cuS9JxYlIBtm8IRcsJ5C46AR6OdGp2gQo885mycWvB03nOg+ICGl C7OLsO0v53Pxvvt1dxygDnsZ7qNtdhDPtHN3hVIZIK/tx+fL3F7icD64N5nJ9iVQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1pHtQV-004oup-0p; Tue, 17 Jan 2023 22:23:27 +0100 Message-ID: <6fb9fc37203bab5082603caf4b4fbecdd3241541.camel@sipsolutions.net> Subject: Re: [PATCH net-next] wifi: ipw2200: use strscpy() to instead of strncpy() From: Johannes Berg To: yang.yang29@zte.com.cn, 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 Date: Tue, 17 Jan 2023 22:23:25 +0100 In-Reply-To: <202212231056165052797@zte.com.cn> References: <202212231056165052797@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:56 +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/intel/ipw2x00/ipw2200.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) >=20 > diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2200.c b/drivers/net/w= ireless/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, str= uct device_attribute *attr, >=20 > IPW_DEBUG_INFO("enter\n"); >=20 > - strncpy(buffer, buf, len); > - buffer[len] =3D 0; > + strncpy(buffer, buf, len + 1); >=20 Ummm? But anyway - why bother ... ancient drivers, clearly OK code. johannes