Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp2857169rwl; Tue, 27 Dec 2022 00:13:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXtAaRyMQEW4RxzTUSRdQbONTUdRXlhTctNFhod5PthWtD5plCJq8dYJm49sJl48f8girwuP X-Received: by 2002:a17:906:33d0:b0:7e0:e1a2:dd98 with SMTP id w16-20020a17090633d000b007e0e1a2dd98mr18767019eja.67.1672128787218; Tue, 27 Dec 2022 00:13:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672128787; cv=none; d=google.com; s=arc-20160816; b=vRSJTT1hKo0H1/d91Qq7bdmNLCwwuxgRUeauBWzbv2f1fIZJb+04jwc37ZGg3R6MmP pkZS16avVQYd0OIfmdxOhN2UixpaxDBf3TXed76Lmxa5dz/gKT/Dqr5qcVfNdA+IXLCM 07e40HmiMxCr5OFroDJLK1S4qC2s9mUTs8JHlaa0pTzSs8LZnP8OXe905QzJa3bXLZbv vnmi1d4wNTNPo8IO/j27Uz4IgwEo6lqq+UNY/32gS/RnSjKyCkHtn8wOTY1Um0z7TBwQ WfjirnXouBcksgRMD7FFFo6eEAz7v4sM7t9NtUPiqnth8qRVtYaX+YoUGYDACiSbQs1E dVZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=fODOEWcfgAX3+4RuskY/mSaCK0Lax7VNa54wZHxL8m0=; b=ib1COC8Ma2zYFiF2/ghQyxx+efSbW1rZbMkmHX39ZTKiV8yB5sLz+JDH5HMV7Cnb4d Ux7KLHMSKAtLZlohVGxJrLp3fV+GNAjFyzwQb7bLnf3FA3GG5muD3TUpsy29IeHZfy95 Ljx2Px3V4fHXsESScKBD/A7NkPK+HGYlD1sM458IBZuevfOyNc5KoXKsQ3wlKzQqO+2y t+4aNSvSWdjlT9PfLXmplhWF4QxFkSd4aRuqPgJyITIrtdlH9o/04p7ryNp8fgoVpntQ 9gGxIL6vXC8s7kSa2pnCcJUx9nQjVKacTtMcK5PTBu3OQ5Sz2TgB3eq+tVqJ7/RDl629 BHQg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb3-20020a1709071c8300b007adf3ed5d20si11413019ejc.376.2022.12.27.00.12.51; Tue, 27 Dec 2022 00:13:07 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230228AbiL0HyJ (ORCPT + 67 others); Tue, 27 Dec 2022 02:54:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230286AbiL0HyD (ORCPT ); Tue, 27 Dec 2022 02:54:03 -0500 X-Greylist: delayed 402 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 26 Dec 2022 23:54:01 PST Received: from mail.sf-mail.de (mail.sf-mail.de [IPv6:2a01:4f8:1c17:6fae:616d:6c69:616d:6c69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 567926561 for ; Mon, 26 Dec 2022 23:54:01 -0800 (PST) Received: (qmail 7681 invoked from network); 27 Dec 2022 07:47:15 -0000 Received: from dyn.ipv6.net-htp.de ([2a02:560:5628:3900:ecef:1c71:d0b:2fa4]:49250 HELO daneel.sf-tec.de) (auth=eike@sf-mail.de) by mail.sf-mail.de (Qsmtpd 0.38dev) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPSA for ; Tue, 27 Dec 2022 08:47:15 +0100 From: Rolf Eike Beer To: james.bottomley@hansenpartnership.com, yang.yang29@zte.com.cn Cc: deller@gmx.de, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, xu.panda@zte.com.cn, yang.yang29@zte.com.cn Subject: Re: [PATCH linux-next v2] parisc: use strscpy() to instead of strncpy() Date: Tue, 27 Dec 2022 08:47:05 +0100 Message-ID: <2298026.kkTNVCUfUN@daneel.sf-tec.de> In-Reply-To: <202212261840048448622@zte.com.cn> References: <202212261840048448622@zte.com.cn> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2316597.IaFIOm8ydW"; micalg="pgp-sha1"; protocol="application/pgp-signature" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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-kernel@vger.kernel.org --nextPart2316597.IaFIOm8ydW Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii"; protected-headers="v1" From: Rolf Eike Beer To: james.bottomley@hansenpartnership.com, yang.yang29@zte.com.cn Date: Tue, 27 Dec 2022 08:47:05 +0100 Message-ID: <2298026.kkTNVCUfUN@daneel.sf-tec.de> In-Reply-To: <202212261840048448622@zte.com.cn> References: <202212261840048448622@zte.com.cn> Am Montag, 26. Dezember 2022, 11:40:04 CET schrieb yang.yang29@zte.com.cn: > From: Xu Panda > > 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 > Signed-off-by: Yang Yang > --- > change for v2 > - sizeof(in) is better and simplified, thanks for Helge Deller. > --- > drivers/parisc/pdc_stable.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c > index d6af5726ddf3..d3075445260b 100644 > --- a/drivers/parisc/pdc_stable.c > +++ b/drivers/parisc/pdc_stable.c > @@ -274,8 +274,7 @@ pdcspath_hwpath_write(struct pdcspath_entry *entry, > const char *buf, size_t coun > > /* We'll use a local copy of buf */ > count = min_t(size_t, count, sizeof(in)-1); > - strncpy(in, buf, count); > - in[count] = '\0'; > + strscpy(in, buf, sizeof(in)); What is "count" now needed for? Looks like a write only variable at least in these hunks. Eike --nextPart2316597.IaFIOm8ydW Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQSaYVDeqwKa3fTXNeNcpIk+abn8TgUCY6qi+QAKCRBcpIk+abn8 TreFAJsGRGXqTM4D8ib9NJdGgqNbpJTmUgCeNNVn9q3szniJshUbN+h2L4zJ5sI= =oo7x -----END PGP SIGNATURE----- --nextPart2316597.IaFIOm8ydW--