From patchwork Wed Nov 9 13:32:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yang X-Patchwork-Id: 17543 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp337697wru; Wed, 9 Nov 2022 05:38:03 -0800 (PST) X-Google-Smtp-Source: AMsMyM5pddq0JExGXyYOgKKPI61+hxYOzoUciV8gsKirOdfga+kdxcGdJ59AG0pPZbkUEX5hxoJ3 X-Received: by 2002:a63:4042:0:b0:43b:ddc8:235 with SMTP id n63-20020a634042000000b0043bddc80235mr52511946pga.498.1668001083062; Wed, 09 Nov 2022 05:38:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668001083; cv=none; d=google.com; s=arc-20160816; b=YIwQEiNSoCVj2weBpbUJahV9tx+SIHIDhHrO5Dm+7ZsYvF0jLjfBESvuZYp9MGa0uJ 1f1lHa5EDYTWdDCtzb0KYsjsPzUJxpWXprituxbJHCgK5ela3yaA9TtwXUwaf0h+nKU+ xOqts4X7s1p8gaOgag2neQyR/ISwURqGC0FqFppQla4nbz5m2c9ky75IMRAXHwM+bpyi X5WnHz6rLvSf/pgOxSWlpKP8sjxrS6sRRSlVx4qYF+ytdl9PxjILip2sUDVot/Loy8iM N3egs/vi0dUlMMOu+P88l2k8+kGhLPFTFzu6k0kQaTJs+NHBaupJtwBrxkKZtdh+cdh0 c0kg== 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=zYMpoPnBfIHpGwNO7qeOEKDAA44g7R5Z66jrC/KbZUQ=; b=y3CUZpJy6J6LI3c8UynIb8op4sN+kOUzzyy5J2p7RdUgIC7oIAOayGeohxKXQjaA56 bw8l9yhvLY5z2tK1Bj7TCB3xo6ChTz9h855/5TP5y5FxYLrDrSnoz3gcDmVDMxzYfjhx vO8v4oakYZf6l5jmgtlF/V+kSyXxPxCr1v7wJplRNsIPLrgs5QXY5Kylfe+GUH6KcqdB mePVIF5YrKQxrV0+hlVnz/wFRwe597obYk/OT9Jo2vJ4Cv2/ja1caBAUzZqBTDpHyQOL 74w57sBEE6gklBRuZf8xDgEzExnNj9RYL03k6E1ETl0eUrgx3G0DwfWIy3sYdQwmLiNs QNCQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y9-20020a170902b48900b00175430821b1si14863559plr.430.2022.11.09.05.37.47; Wed, 09 Nov 2022 05:38:03 -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 S229561AbiKINc7 (ORCPT + 99 others); Wed, 9 Nov 2022 08:32:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbiKINc6 (ORCPT ); Wed, 9 Nov 2022 08:32:58 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A644B2EF39 for ; Wed, 9 Nov 2022 05:32:56 -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 mxhk.zte.com.cn (FangMail) with ESMTPS id 4N6m9z25qSz8QrkZ; Wed, 9 Nov 2022 21:32:55 +0800 (CST) Received: from szxlzmapp01.zte.com.cn ([10.5.231.85]) by mse-fl2.zte.com.cn with SMTP id 2A9DWnZt099946; Wed, 9 Nov 2022 21:32:49 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp03[null]) by mapi (Zmail) with MAPI id mid14; Wed, 9 Nov 2022 21:32:53 +0800 (CST) Date: Wed, 9 Nov 2022 21:32:53 +0800 (CST) X-Zmail-TransId: 2b05636bac05ffffffff8eb2a033 X-Mailer: Zmail v1.0 Message-ID: <202211092132530746481@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , Subject: =?utf-8?q?=5BPATCH_linux-next=5D_block=3A_use_strscpy=28=29_is_more?= =?utf-8?q?_robust_and_safer?= X-MAIL: mse-fl2.zte.com.cn 2A9DWnZt099946 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 636BAC07.000 by FangMail milter! X-FangMail-Envelope: 1668000775/4N6m9z25qSz8QrkZ/636BAC07.000/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 636BAC07.000/4N6m9z25qSz8QrkZ 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749025903965358823?= X-GMAIL-MSGID: =?utf-8?q?1749025903965358823?= From: Xu Panda The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL terminated strings. Reported-by: Zeal Robot Signed-off-by: Xu Panda Signed-off-by: Yang Yang --- block/elevator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/elevator.c b/block/elevator.c index a5bdc3b1e7e5..0885b66c3868 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -749,7 +749,7 @@ ssize_t elv_iosched_store(struct request_queue *q, const char *buf, if (!elv_support_iosched(q)) return count; - strlcpy(elevator_name, buf, sizeof(elevator_name)); + strscpy(elevator_name, buf, sizeof(elevator_name)); ret = elevator_change(q, strstrip(elevator_name)); if (!ret) return count;