Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2306392rwb; Thu, 8 Dec 2022 23:53:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Is86FeCIcP/qGXxrPq+wYYInK8orbkllH2vRMBozp1pUWFPpKP0CmVzkd84r3VW292As5 X-Received: by 2002:a05:6a20:958b:b0:a3:ca9a:ff82 with SMTP id iu11-20020a056a20958b00b000a3ca9aff82mr6596573pzb.61.1670572395599; Thu, 08 Dec 2022 23:53:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670572395; cv=none; d=google.com; s=arc-20160816; b=UtZ0pzXEPiT1lcPRugziK63XB7M9ejHtV+Rcnf4IyvVFU0JDYE3u/E4cR4kw0BxBdg mXYGE93RFBnn62WK6MwBfvXBYyaNACSODLMNe6TBHXhQl7zSgJ+bHFiiQ91e5aaFuX8K Y3XP8ileJjt7/vB8IHB/eBOr1fgsUYFPMDD+MdLO2XaLFrD17rfplq/lDHfBCihXpMgQ 926eIM42yMCC6S6rtCfN3voKbkNPlXbZgTpyJrnibXCjXm7PTfGXHQE3UmyClcqIr+FP 4S/Pis75M6L60hmzFwA/SmmyuQOEs/JP62YUP7G85qPQNy0vPzXdJbD+BJbtbjtn84/X Gtyw== 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=cRq8OZw0T+NRmPIKDDa9QSFjiOlz4YvG51Gj49HazqQ=; b=KY9MFVUIIzLKZZ4Ip9u+KylYPLFz9ko5Fy6GOSRxo4xQi/a6zM55assrDOu+PdAZd7 ruXIQGVCyDNSfX6QpfdUajh7GYiu4LZRY52EZBYr12rVBWt/V97d4amoSjabojyAz6/Q Jca1dR8rOL29OX62jtlIoXf+nlPwkZEwZOrMN18Ik9c8CYkdhup14AG+dWn2G8oba1Gk S73qgsUOqq6ODWcHS9pCBD/tlaMGP0+jYWlqNIAeM4EAOuMGHK/raLh2lIlxgJ2r1UMA dd+DUaZ+oxjpPjN3zMWoib3nauSKvl1XYSBCamSuKlDyMxexhfRagu7XqQFkXHiu/oLX k0Sg== 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 l19-20020a656813000000b0047701a21acfsi851252pgt.604.2022.12.08.23.53.05; Thu, 08 Dec 2022 23:53: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 S229956AbiLIHhm (ORCPT + 73 others); Fri, 9 Dec 2022 02:37:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229550AbiLIHhk (ORCPT ); Fri, 9 Dec 2022 02:37:40 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EE3B271A; Thu, 8 Dec 2022 23:37:37 -0800 (PST) Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (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 4NT2t81pcSz8R043; Fri, 9 Dec 2022 15:37:36 +0800 (CST) Received: from szxlzmapp01.zte.com.cn ([10.5.231.85]) by mse-fl1.zte.com.cn with SMTP id 2B97bRCt037067; Fri, 9 Dec 2022 15:37:27 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp04[null]) by mapi (Zmail) with MAPI id mid14; Fri, 9 Dec 2022 15:37:29 +0800 (CST) Date: Fri, 9 Dec 2022 15:37:29 +0800 (CST) X-Zmail-TransId: 2b066392e5b9ffffffffc3dd0771 X-Mailer: Zmail v1.0 Message-ID: <202212091537298224990@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , Subject: =?UTF-8?B?W1BBVENIIG5ldC1uZXh0IHYyXSBteXJpMTBnZTogdXNlIHN0cnNjcHkoKSB0byBpbnN0ZWFkIG9mIHN0cm5jcHkoKQ==?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 2B97bRCt037067 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 6392E5C0.000 by FangMail milter! X-FangMail-Envelope: 1670571456/4NT2t81pcSz8R043/6392E5C0.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6392E5C0.000/4NT2t81pcSz8R043 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, 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 --- change for v2 - change the subject and prefix, replace linux-next with net-next. --- 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