Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6116164rwl; Mon, 9 Jan 2023 04:31:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXue+DWb4ReProzBE1DU5HONUCEGt+sp7yYxKL+LfAqKbO2yu8db85XNrQqOpw7Hk/07WiT7 X-Received: by 2002:a17:906:79d2:b0:7ae:987d:d7f9 with SMTP id m18-20020a17090679d200b007ae987dd7f9mr50104811ejo.17.1673267473927; Mon, 09 Jan 2023 04:31:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673267473; cv=none; d=google.com; s=arc-20160816; b=F3nObJiZIvgnCVAytnHvkDbE749MWuCeigRPqhA64T+WkDjkiTM/wxrDM/VaZKPqGD 5S38jhaCNQG3rcXHDtSwGtv4Zr0/0LWwzM0q6r6jhsGDM/knnjYP2fRGmEg2AEEVk+rc HEs4t0Hg26p9G8yCa7SwNeSsRSYDEB7oy7+QID1KK5HG24rFnqT/QRDGLjOI5GnqkVRF 6KaOV93CjmlibqW+5SFbEiVvWyD2DDqzag4AKGWUE72EC4k0tCpBXjc8LV+whzee7gVC GNnTjiDCvdl4JwhJc7qiwFkr7tuqVolNyEr6yPtPPle9GjQXqPyObBrYrh4C+YOAKvEd rK/w== 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=XGVUICpWVcIvOeTWCchQM7Tcr0OgyA4LuTojL88/be0=; b=czNWvofgZezPhKQzbLHhstQDJ25ZUYyGNU6F/d32wmkNvE+9g3x/qn034py2azMkYU fIGJUqpUus1bxCjOmTjg0HwyjO0fZrFeIlSIAmTOOqJCVoDvlsP8cw/fPCyUA1VQWIZr +eRMVjrk+U8/cF2Tb83hNnbOKKo1MKVuRxIsUhL0/pvh1DvrUxFxRyguOJemuE2nP8No IvTJalBNOiW6T+FmRtw3ZwKQtqovd5AQRgXylFHUhY7H2liwds5VXHJxSzj5IUX9xcGd r2UEZr8rIwnjnqWTMnDHTgZjQfdEyKEspLO9C0ODa7KSZI8ktkgFMmlIhF0jDFLyGPx+ KODw== 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 gv11-20020a1709072bcb00b0084c7e7eb6fesi7198551ejc.452.2023.01.09.04.31.01; Mon, 09 Jan 2023 04:31:13 -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 S236931AbjAILtE (ORCPT + 53 others); Mon, 9 Jan 2023 06:49:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237075AbjAILst (ORCPT ); Mon, 9 Jan 2023 06:48:49 -0500 Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18801D120; Mon, 9 Jan 2023 03:48:48 -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 4NrBzc6Kznz4y3Z8; Mon, 9 Jan 2023 19:48:44 +0800 (CST) Received: from szxlzmapp02.zte.com.cn ([10.5.231.79]) by mse-fl2.zte.com.cn with SMTP id 309Bmers067416; Mon, 9 Jan 2023 19:48:40 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp01[null]) by mapi (Zmail) with MAPI id mid14; Mon, 9 Jan 2023 19:48:43 +0800 (CST) Date: Mon, 9 Jan 2023 19:48:43 +0800 (CST) X-Zmail-TransId: 2b0363bbff1bffffffffabae1a6f X-Mailer: Zmail v1.0 Message-ID: <202301091948433010050@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , , Subject: =?UTF-8?B?W1BBVENIIG5ldC1uZXh0XSBuZXQvcmRzOiB1c2Ugc3Ryc2NweSgpIHRvIGluc3RlYWQgb2Ygc3RybmNweSgp?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl2.zte.com.cn 309Bmers067416 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.251.13.novalocal with ID 63BBFF1C.000 by FangMail milter! X-FangMail-Envelope: 1673264924/4NrBzc6Kznz4y3Z8/63BBFF1C.000/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63BBFF1C.000/4NrBzc6Kznz4y3Z8 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 --- net/rds/stats.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/rds/stats.c b/net/rds/stats.c index 9e87da43c004..6a5a60d36d60 100644 --- a/net/rds/stats.c +++ b/net/rds/stats.c @@ -89,8 +89,7 @@ void rds_stats_info_copy(struct rds_info_iterator *iter, for (i = 0; i < nr; i++) { BUG_ON(strlen(names[i]) >= sizeof(ctr.name)); - strncpy(ctr.name, names[i], sizeof(ctr.name) - 1); - ctr.name[sizeof(ctr.name) - 1] = '\0'; + strscpy(ctr.name, names[i], sizeof(ctr.name)); ctr.value = values[i]; rds_info_copy(iter, &ctr, sizeof(ctr)); -- 2.15.2