Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2306946rwb; Thu, 8 Dec 2022 23:54:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf5lWtItKbTV/S9K6x5AlnjoTDj9W/eR7SU/TiwprQMAUzJLVfuKifcSRwLB0Jy07/JqBRa3 X-Received: by 2002:a17:90a:db97:b0:21b:c5b5:a6f4 with SMTP id h23-20020a17090adb9700b0021bc5b5a6f4mr5056918pjv.13.1670572441402; Thu, 08 Dec 2022 23:54:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670572441; cv=none; d=google.com; s=arc-20160816; b=b7UBZV9vmlti9ZUOkx042FDHF7B5L+H8rSj/Bm4Z4GCUQEAuUajAl5FAl3j+/WX3Ni cTWjiLy6v1exrbyXi2+CR5gxz52UMHZs4kQjfJRyU8McxLTvlRQ+corzjAU13b9NScEY VQFTA5O/+sINb1111VBFKJh1ALUIvgn8frQEgh8z1WTjwGwa9rMkRGYNfnSesTS1bblC 0Aq4U53DWlOqPMHZ5oCSU8TGupLF85MvnKS2UYHWCaxVclykMf9yjU7YKzfmf9ozScSb cZbP55Fz/56wGC4SzCm0jYH7Rw5Bit5wJxEM8GYDibN/ZyAa/vcqD3MfiU9otXIAuSN8 ZO8Q== 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=99Fzxo8kbWbiVN0mg9Uzq6d9GHXnfo8f7ylmEadNu5I=; b=Ph0AFJUYtUoylnTTScAgvrc0gVYurBzOdVM3mFQVdqlsBt3RLy7m6a0ChK33uA2xFX mUTyBXicwDDTn8ZXivVOZEPyOwoYY0dSGyfLSzjDRBZSM9Qie8MHMv3cWuxHonoGl4CX mBoI2IgoZQYAHPxkIxklHHLcvei0JhXJO59+bCo6a8mAlTkWpESZ3TIyUH5Y5juAWa+R 5d+FqKY68Yg6HFDZWqnJcIIh2JH4WFgOIjyWB9pFZpSYaZ8YgAqieCysOO2OwhMjb4rY nG/XFqHDyZ4Cqp0kUC0XHubUgkkHWgrIGHZsrP7XT9AnsO6xbmrpGtoLq8/JpOYCDUOl 4JXw== 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 x184-20020a6363c1000000b0046b19725686si810568pgb.775.2022.12.08.23.53.51; Thu, 08 Dec 2022 23:54:01 -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 S229561AbiLIHfC (ORCPT + 74 others); Fri, 9 Dec 2022 02:35:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229550AbiLIHfA (ORCPT ); Fri, 9 Dec 2022 02:35:00 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51BBA195; Thu, 8 Dec 2022 23:34:59 -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 4NT2q60Hj0z8R039; Fri, 9 Dec 2022 15:34:58 +0800 (CST) Received: from szxlzmapp07.zte.com.cn ([10.5.230.251]) by mse-fl1.zte.com.cn with SMTP id 2B97Yk6Y033797; Fri, 9 Dec 2022 15:34:46 +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:34:49 +0800 (CST) Date: Fri, 9 Dec 2022 15:34:49 +0800 (CST) X-Zmail-TransId: 2b066392e519360cae99 X-Mailer: Zmail v1.0 Message-ID: <202212091534493764895@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , , Subject: =?UTF-8?B?W1BBVENIIG5ldC1uZXh0IHYyXSBsaXF1aWRpbzogdXNlIHN0cnNjcHkoKSB0byBpbnN0ZWFkIG9mIHN0cm5jcHkoKQ==?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 2B97Yk6Y033797 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 6392E522.000 by FangMail milter! X-FangMail-Envelope: 1670571298/4NT2q60Hj0z8R039/6392E522.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6392E522.000/4NT2q60Hj0z8R039 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, replace linux-next with net-next. --- drivers/net/ethernet/cavium/liquidio/octeon_console.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_console.c b/drivers/net/ethernet/cavium/liquidio/octeon_console.c index 28feabec8fbb..67c3570f875f 100644 --- a/drivers/net/ethernet/cavium/liquidio/octeon_console.c +++ b/drivers/net/ethernet/cavium/liquidio/octeon_console.c @@ -247,8 +247,7 @@ static const struct cvmx_bootmem_named_block_desc struct cvmx_bootmem_named_block_desc, size)); - strncpy(desc->name, name, sizeof(desc->name)); - desc->name[sizeof(desc->name) - 1] = 0; + strscpy(desc->name, name, sizeof(desc->name)); return &oct->bootmem_named_block_desc; } else { return NULL; @@ -471,8 +470,8 @@ static void output_console_line(struct octeon_device *oct, if (line != &console_buffer[bytes_read]) { console_buffer[bytes_read] = '\0'; len = strlen(console->leftover); - strncpy(&console->leftover[len], line, - sizeof(console->leftover) - len); + strscpy(&console->leftover[len], line, + sizeof(console->leftover) - len + 1); } } -- 2.15.2