Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2309716rwb; Thu, 8 Dec 2022 23:57:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf5uDQhbuvXbLl5oTm/oJfAY19C97Bny7IYeqnSYODl8vnDa5/HxN4Jnqx27o9v6+Gw+35v2 X-Received: by 2002:a05:6402:1f08:b0:462:330a:ce35 with SMTP id b8-20020a0564021f0800b00462330ace35mr5703742edb.11.1670572630462; Thu, 08 Dec 2022 23:57:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670572630; cv=none; d=google.com; s=arc-20160816; b=QIHlw+wq+GdrdFRq+NmLoCszeGBsnv3lgD9x2+6nBvyO675MN0uqX8N7VfyIPUpMll +1/eNtg2B42GpOclPt7Qm/zbBk4i5UVIwk4rT44gzkJ/r3+9MmON2XwNEfA3n6HQJn9I TU4Fg1DUQ+WByT0QmDzVN7iIne21ogyvDMWxUrRcIz6Rekor/5oujVpnziumYTEbdFGD AYp8rlzvbu7Qre3vpEVmerFaTDF/Dh7oFcodDp4wJYBC8RZ9H0PSqykWaNIu4W+4CIRm UTwyVw6MWBsSfF/tkaZWlRZQDk8QySMiVid733DFTxM48MYeHuCG9oiUCYKgYX1eo+uj T6iw== 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=Vxct0tAHXpAHvaTTsoRi2l5+vDP/h/9o41nfNO1xRKg=; b=n9REJkpxFBKJfVyHA8P50qDxoDjTnmuP3tFl6V/nKn/vED4b3zUPmY2dZF0MWFOJuJ lMh56nUG87ZGemdqTX/Yx7qlk9Ir5agPptC7z5aUGZo4g7F1a3Yg8rsj7ldfdYENH283 MViZl8YLPvdtFbIN06E85iuNNredffSEvruyuko+zpQBrzEWU/OOGWyJOVHULrPwoQxY K7oR9T/JWi/94ANcgyj2vsAsHU07wCGe/gV39AwdXmi5I4CjSdu00uNR6SMEwef3x4Hy XNzat3vVUdq3ME5jef0vpRoXB/X3/6sj/HN1c9HB7DlmJeEI6kQKF3B11KIKc8af9ViT oXMA== 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 d25-20020a056402079900b00461c7ad026csi718652edy.61.2022.12.08.23.56.52; Thu, 08 Dec 2022 23:57:10 -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 S229896AbiLIHps (ORCPT + 75 others); Fri, 9 Dec 2022 02:45:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbiLIHpp (ORCPT ); Fri, 9 Dec 2022 02:45:45 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C789540900; Thu, 8 Dec 2022 23:45:44 -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 4NT33W18jGz8QrkZ; Fri, 9 Dec 2022 15:45:43 +0800 (CST) Received: from szxlzmapp02.zte.com.cn ([10.5.231.79]) by mse-fl1.zte.com.cn with SMTP id 2B97jScJ046261; Fri, 9 Dec 2022 15:45:28 +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:45:31 +0800 (CST) Date: Fri, 9 Dec 2022 15:45:31 +0800 (CST) X-Zmail-TransId: 2b066392e79b6cce31ed X-Mailer: Zmail v1.0 Message-ID: <202212091545310085328@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , , , , , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHQgdjNdIHg4Ni9wbGF0Zm9ybS91djogdXNlIHN0cnNjcHkgdG8gaW5zdGVhZCBvZiBzdHJuY3B5KCk=?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 2B97jScJ046261 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 6392E7A7.000 by FangMail milter! X-FangMail-Envelope: 1670571943/4NT33W18jGz8QrkZ/6392E7A7.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6392E7A7.000/4NT33W18jGz8QrkZ 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 v3 - remove the remaining definition of p, and fix the mistake which leads to eating one character. Thanks to Andy Shevchenko again. --- arch/x86/platform/uv/uv_nmi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/platform/uv/uv_nmi.c b/arch/x86/platform/uv/uv_nmi.c index a60af0230e27..a55550b779e1 100644 --- a/arch/x86/platform/uv/uv_nmi.c +++ b/arch/x86/platform/uv/uv_nmi.c @@ -202,14 +202,10 @@ static int param_set_action(const char *val, const struct kernel_param *kp) { int i; int n = ARRAY_SIZE(valid_acts); - char arg[ACTION_LEN], *p; + char arg[ACTION_LEN]; /* (remove possible '\n') */ - strncpy(arg, val, ACTION_LEN - 1); - arg[ACTION_LEN - 1] = '\0'; - p = strchr(arg, '\n'); - if (p) - *p = '\0'; + strscpy(arg, val, strnchrnul(val, ACTION_LEN - 1, '\n') - val + 1); for (i = 0; i < n; i++) if (!strcmp(arg, valid_acts[i].action)) -- 2.15.2