Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp951905rwb; Thu, 8 Dec 2022 05:10:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf4n1XuqIrG9tIsEWZwnznlkUGykkbjgPXQckxoOSRPwDW7VaVZ8CT+umfezORY7FPk8Oezs X-Received: by 2002:a17:906:9709:b0:7c0:cb51:887c with SMTP id k9-20020a170906970900b007c0cb51887cmr21170248ejx.620.1670505014247; Thu, 08 Dec 2022 05:10:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670505014; cv=none; d=google.com; s=arc-20160816; b=ynvazKx+cPJH+BtmDNC96S14a4Qw2lyhhhoPnzzxrOerndwdJzyvlwVRsetAZqRu7A OYWDn20qwESKljTQWDlVmu4JhEmD+8IkDJH+uFnVoVjMpp3CwLf8QU5Paf5BHGdLoWPS qXCCfGLSkZYCVm5B/faR3IDPJ95xk1Wx15Zip/dbz/lC8x5aOZIN8BnnybYsDDxPu93E GjnImFd9d23AnyRgD/yPMfciyiM/jxjmbaa3f8HukYv8VCxNN57Pujy91B51BKW0a6Cv W+ovMyzgcobTPfmKJDfi/67l7uV9r7tyJnma94eZL5SrewSG5vq8weCp2Y79vCrxO+D4 uh8g== 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=2Ot9WwkvOFqgtJYlTJjnL4pdveXJbYPLJDxuzOZFdvU=; b=NvParPZaZez80yIp/X9iUNSGVR5amooy9g7uB4Vlzbm2N3Jy2BSZElNEWTjMOA5Bxk oMLUzL4E4NHPIwkjaMcEqg04Iy1KK+7pIny5bDK6FThtxtbIlOm9VasK+nlOgRnSoBkW qVa0WiDcRguR0Pl9DmNSUlUlLRwgdlzHJ0TMBLEqWQ4DAXeejw1tx4YlA9nIJdosMq1Y 3G145rb014IAX6D9IG0iOsQwpwqEg4AZUBDOZPWRbGMCOlvC/vOvfrRDH3q4GZ2Z/skv RMsvCWs1PCz/Oyt36MDFr9FyPyU0e31I8oa456BNEHb+Y/xfmMr+c19qmkug6AmHPCFk CQlA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ne42-20020a1709077baa00b007807e1f3d9dsi18667604ejc.842.2022.12.08.05.09.55; Thu, 08 Dec 2022 05:10:14 -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 S229957AbiLHLxo (ORCPT + 72 others); Thu, 8 Dec 2022 06:53:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230182AbiLHLxR (ORCPT ); Thu, 8 Dec 2022 06:53:17 -0500 Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E78108C683; Thu, 8 Dec 2022 03:52:14 -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 mxct.zte.com.cn (FangMail) with ESMTPS id 4NSXZN5zWlz4y0vY; Thu, 8 Dec 2022 19:52:12 +0800 (CST) Received: from szxlzmapp02.zte.com.cn ([10.5.231.79]) by mse-fl2.zte.com.cn with SMTP id 2B8Bq0sw020241; Thu, 8 Dec 2022 19:52:00 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp04[null]) by mapi (Zmail) with MAPI id mid14; Thu, 8 Dec 2022 19:52:03 +0800 (CST) Date: Thu, 8 Dec 2022 19:52:03 +0800 (CST) X-Zmail-TransId: 2b066391cfe33482c21d X-Mailer: Zmail v1.0 Message-ID: <202212081952034833496@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIG5ldDogZXRoZXJuZXQ6IHVzZSBzdHJzY3B5KCkgdG8gaW5zdGVhZCBvZiBzdHJuY3B5KCnCoA==?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl2.zte.com.cn 2B8Bq0sw020241 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.251.13.novalocal with ID 6391CFEC.000 by FangMail milter! X-FangMail-Envelope: 1670500332/4NSXZN5zWlz4y0vY/6391CFEC.000/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6391CFEC.000/4NSXZN5zWlz4y0vY 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/net/ethernet/myricom/myri10ge/myri10ge.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c index 9063e2e22cd5..8073d7a90a26 100644 --- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c +++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c @@ -552,8 +552,7 @@ myri10ge_validate_firmware(struct myri10ge_priv *mgp, } /* save firmware version for ethtool */ - strncpy(mgp->fw_version, hdr->version, sizeof(mgp->fw_version)); - mgp->fw_version[sizeof(mgp->fw_version) - 1] = '\0'; + strscpy(mgp->fw_version, hdr->version, sizeof(mgp->fw_version)); sscanf(mgp->fw_version, "%d.%d.%d", &mgp->fw_ver_major, &mgp->fw_ver_minor, &mgp->fw_ver_tiny); -- 2.15.2