Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5801617rwb; Mon, 5 Dec 2022 04:26:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf4WXrNuhzs+oZK2g8zVw2VCBppg3UfDTx+snrLviO9BYX2Rr8pdcR2rq1f+SP661kaJ98yI X-Received: by 2002:a17:906:81c7:b0:7c0:d5b0:db37 with SMTP id e7-20020a17090681c700b007c0d5b0db37mr8189442ejx.316.1670243183871; Mon, 05 Dec 2022 04:26:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670243183; cv=none; d=google.com; s=arc-20160816; b=rGYF5EkDB2pb4r+aPSXXwExnt0ipF0ZS4E/rbR73pm/TsldwfKBFMzZShp4StqZHD+ 1ItVCEbX4oYWuAz7TB5YMhMmkKTNef10gzRkChlU7DmjGYvU08Kw+P8SUxjuk5QHaBN2 bJ49cvsqNfhPEtdUetlNenyi7aQSt9a2Obv696WIsCnFVR949oqXQtdLn98Z682f5Re6 vUJVta5Y44Sop/mKCrmueua//Q71Ox2vlde0QLyQlqdKKpoENMvsSCJdASPlf1AvCPYa ZoUZM32K8qvqFyg0er1YgSX2B23vXj/qgbi7J9lwzYUmwAW9m7be5GJ5+7QiyzT1xI0u df4g== 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=GuLgUHbXLStKbqczWJizrWRjthdRFoJH/JGiqEkxvcY=; b=k3z9cx3vjMiNM5KTR8sMlHUBXUQk2m/WoOB0otD0d3OiwIIr/lDalZhBu4WJQMLeY9 +3WsWU98FyZVFt5SLxvDKsQ/1wBQfNBwcAC6dZmthCYolGRJEnaE2xu5OdVeqiiSeqlB dlX3ckbcgJCMpr9tnFdLAZ1lp2toVpQoCN3qKNZZfjIAmMOyrJvdZFelgtv1FmJbYtaA vJxj2KgyFOl5G0O+DRNQHX8Sdvg0BK3j4sWkIacZl+R0H/jFFlwVAZoEBh5Td76EJG1L lVUR6vgNeu2DhwXxfvqiLAekoeoMdYKFrMAuUKWuB0UbUz8zQ30jxC7aZJkXXnxHxtjI YCww== 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 vh12-20020a170907d38c00b007adef1dceffsi10224236ejc.677.2022.12.05.04.26.02; Mon, 05 Dec 2022 04:26:23 -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 S231375AbiLELnE (ORCPT + 82 others); Mon, 5 Dec 2022 06:43:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231421AbiLELmV (ORCPT ); Mon, 5 Dec 2022 06:42:21 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B609A1A212; Mon, 5 Dec 2022 03:42:10 -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 4NQhV92nnZz8RTZG; Mon, 5 Dec 2022 19:42:09 +0800 (CST) Received: from szxlzmapp07.zte.com.cn ([10.5.230.251]) by mse-fl1.zte.com.cn with SMTP id 2B5Bg4xo053795; Mon, 5 Dec 2022 19:42:04 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp02[null]) by mapi (Zmail) with MAPI id mid14; Mon, 5 Dec 2022 19:42:08 +0800 (CST) Date: Mon, 5 Dec 2022 19:42:08 +0800 (CST) X-Zmail-TransId: 2b04638dd91003fa7628 X-Mailer: Zmail v1.0 Message-ID: <202212051942082259437@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , , , , , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHQgdjJdIHg4Ni9wbGF0Zm9ybS91djogdXNlIHN0cnNjcHkgdG8gaW5zdGVhZCBvZiBzdHJuY3B5KCk=?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 2B5Bg4xo053795 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 638DD911.001 by FangMail milter! X-FangMail-Envelope: 1670240529/4NQhV92nnZz8RTZG/638DD911.001/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 638DD911.001/4NQhV92nnZz8RTZG 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. --- change for v2 - fix the mistake and make the code better and simpler, thanks to Andy Shevchenko. --- Signed-off-by: Xu Panda Signed-off-by: Yang Yang Signed-off-by: Andy Shevchenko --- arch/x86/platform/uv/uv_nmi.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/arch/x86/platform/uv/uv_nmi.c b/arch/x86/platform/uv/uv_nmi.c index a60af0230e27..d94140842aa3 100644 --- a/arch/x86/platform/uv/uv_nmi.c +++ b/arch/x86/platform/uv/uv_nmi.c @@ -205,11 +205,7 @@ static int param_set_action(const char *val, const struct kernel_param *kp) char arg[ACTION_LEN], *p; /* (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, '\n') - val); for (i = 0; i < n; i++) if (!strcmp(arg, valid_acts[i].action)) -- 2.15.2