Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3129077rwb; Fri, 2 Dec 2022 22:49:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf7r5h3Ux9scR1W/dR99bUjnF54M02LNUijrelGuwIauQjsimn2LFUsLL9p2ovsisi2OSOVx X-Received: by 2002:a63:1247:0:b0:476:ed2a:6216 with SMTP id 7-20020a631247000000b00476ed2a6216mr59004528pgs.556.1670050142964; Fri, 02 Dec 2022 22:49:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670050142; cv=none; d=google.com; s=arc-20160816; b=d+0embjukPcaOFAVKIXE6juTm1uoOq2VYph/Lh3kx+F7Ozrj0NWrB4cPrYHX/dYtBf eI0W5OCytuCLpp12WWBzbAPOdzF6Azs+pOr1xKCId6pwLTEgpiBIgyrlWgq4v1wMr4EN BAJzVluW1jJPm2PLGDgvoJ0aRVmfpKKsR+cILqE+06+voBi6YVR9HaDoDWh24jRK5yVF jGSMuo4Bx2llwLIY9bC2Uk1gvLgALJ7hshXBQULvNV86fScp1z9/2p71L4Ph55qFLcLU QIuSCaiQ9HDSQmI16N4ZWM8oj0qcthFt7nH1tN2MzxAMBRxhLIpzo7uov9REi5glLX1J 3l8g== 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=YBKFXnz1U7gbi30oeI8P+/z+tKvnPvPVgP3zyHzpzL0=; b=narV7eEj6x9Saxw8BYQOMFpMan7tRNJD92uXpZNwu6gzGX+ldbHXb4nELf23oQr/nO hWo/KaxqW9uw4RheZ+urgMVAZA7HM5hCVB4XDGY1kyDStFuG5sQxqeQ+uRUA33Xh503c HAX1RVaGq12JyZFer7B9P/dIJHAh7cuz0NewbdM2GHk8V5dHnwspEXlfOzL5SY7uqIxP IRhePNpmd0SlG9mfJQfXS3j7joyymQAFQyF+9lW1lcgsSCWcwr9U5FkM6SdZsQKpbSaz +u87bIOX+JikzIviVohUTEcrnw8RoSqN40bnwRyGlv8peFh+qv8f+MLU+JEowGfPwvrm /VHw== 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 pj2-20020a17090b4f4200b0021406fde039si9294950pjb.156.2022.12.02.22.48.53; Fri, 02 Dec 2022 22:49:02 -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 S231154AbiLCGTi (ORCPT + 82 others); Sat, 3 Dec 2022 01:19:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbiLCGTg (ORCPT ); Sat, 3 Dec 2022 01:19:36 -0500 Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0933ED208F; Fri, 2 Dec 2022 22:19:36 -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 mxct.zte.com.cn (FangMail) with ESMTPS id 4NPKQt47vdz4xq1w; Sat, 3 Dec 2022 14:19:34 +0800 (CST) Received: from szxlzmapp07.zte.com.cn ([10.5.230.251]) by mse-fl1.zte.com.cn with SMTP id 2B36JU32087812; Sat, 3 Dec 2022 14:19:30 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp02[null]) by mapi (Zmail) with MAPI id mid14; Sat, 3 Dec 2022 14:19:32 +0800 (CST) Date: Sat, 3 Dec 2022 14:19:32 +0800 (CST) X-Zmail-TransId: 2b04638aea74ffffffff810fbe95 X-Mailer: Zmail v1.0 Message-ID: <202212031419324523731@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIHg4Ni9tY2UvZGV2LW1jZWxvZzogdXNlIHN0cnNjcHkoKSB0byBpbnN0ZWFkIG9mIHN0cm5jcHkoKQ==?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 2B36JU32087812 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.251.13.novalocal with ID 638AEA76.000 by FangMail milter! X-FangMail-Envelope: 1670048374/4NPKQt47vdz4xq1w/638AEA76.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 638AEA76.000/4NPKQt47vdz4xq1w 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 --- arch/x86/kernel/cpu/mce/dev-mcelog.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/dev-mcelog.c b/arch/x86/kernel/cpu/mce/dev-mcelog.c index 100fbeebdc72..a05ac0716ecf 100644 --- a/arch/x86/kernel/cpu/mce/dev-mcelog.c +++ b/arch/x86/kernel/cpu/mce/dev-mcelog.c @@ -105,8 +105,7 @@ static ssize_t set_trigger(struct device *s, struct device_attribute *attr, { char *p; - strncpy(mce_helper, buf, sizeof(mce_helper)); - mce_helper[sizeof(mce_helper)-1] = 0; + strscpy(mce_helper, buf, sizeof(mce_helper)); p = strchr(mce_helper, '\n'); if (p) -- 2.15.2