Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp825289rwl; Thu, 5 Jan 2023 05:13:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXvIwnXDK36kdcMsyD302OS5i+BwAYNfCji/nhsynko/LZpTQZUAz9Q1N8vZe5ZRkG4SDVAv X-Received: by 2002:a62:ee19:0:b0:583:312a:b344 with SMTP id e25-20020a62ee19000000b00583312ab344mr1243692pfi.31.1672924412251; Thu, 05 Jan 2023 05:13:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672924412; cv=none; d=google.com; s=arc-20160816; b=clqU2d0krP+9fP+T53aOFaQv8Eko2Mh2qR0lQ3YkP8Aai/1jeW3F4C/4EoA+SrFOXO 8QZYJV9+qiUfF/pSYDgQCL6bEOWHAfzD2jWmFuSNgv8DHBiotwpo3Ws0L7Fkh1E/SxIB CE993qO3SYDdPRqbiiAhxLJXeZYffmKRZKQnO7z3eu4B1SiP7wt276Pc59H5cXCaNHEr Sguie74K3/v0nUspm2q0BZWJOQlsTrRWW8+paqJya0v2KRrCzd3sZsIG6Hjgl3tXx7ke vu+VKnvFJVPaRI0EjHLCkoyw06mM9wAZuADaMBiqomqkBxTWFW2KLohtQWhQs5Dbj0jI KN/Q== 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=WfZ/m9MQBwSpuo90iUx8JXpjoDVP8NpFAkjP7szIQeo=; b=X1YlidmftJiOElHzQ7oYqVVjIR+04iY14wslnRuGMKJ8ssv8TwKSahzrCm1D6i+O2O /LJSawp8OWG9YafRTKzBfZVCIvtxjCqNICwWnhXEaEx3G6hCWYDU67V7RrEZcdJt8rhD axvrWQ6H2eLYokIGgm+B0oXP9DHHgemPRgFOQK46I4kCG7ZGL35lV2owTLhdO432FibJ 72Lh6Hfi840vaceiU+s99k+mGVnZCiMVpH4DSACAyBnnu/Qqm4YvXnLsNzPvXIbtb4P4 7uEHS4Og0k6yfblxMCFLFpDQwpylvcjzhuqTDxGZZXa06hfW3cqIVzCZ01vWbJQt+OgK 1wig== 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 p9-20020a056a000a0900b00576dc406db3si42151159pfh.172.2023.01.05.05.13.24; Thu, 05 Jan 2023 05:13:32 -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 S233149AbjAEMYq (ORCPT + 55 others); Thu, 5 Jan 2023 07:24:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231616AbjAEMYp (ORCPT ); Thu, 5 Jan 2023 07:24:45 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B5E84E404; Thu, 5 Jan 2023 04:24:44 -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 4Nnlyy4l7hz8QrkZ; Thu, 5 Jan 2023 20:24:42 +0800 (CST) Received: from szxlzmapp06.zte.com.cn ([10.5.230.252]) by mse-fl2.zte.com.cn with SMTP id 305COVcF068055; Thu, 5 Jan 2023 20:24:31 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp01[null]) by mapi (Zmail) with MAPI id mid14; Thu, 5 Jan 2023 20:24:34 +0800 (CST) Date: Thu, 5 Jan 2023 20:24:34 +0800 (CST) X-Zmail-TransId: 2b0363b6c1823267991f X-Mailer: Zmail v1.0 Message-ID: <202301052024349365834@zte.com.cn> Mime-Version: 1.0 From: To: , Cc: , , , , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHQgdjNdIHMzOTAvemNyeXB0OiB1c2Ugc3Ryc2NweSgpIHRvIGluc3RlYWQgb2Ygc3RybmNweSgp?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl2.zte.com.cn 305COVcF068055 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 63B6C18A.001 by FangMail milter! X-FangMail-Envelope: 1672921482/4Nnlyy4l7hz8QrkZ/63B6C18A.001/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63B6C18A.001/4Nnlyy4l7hz8QrkZ 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 --- chang for v3 - fix the sign-off Email address chang for v2 - match the FROM with the Email --- drivers/s390/crypto/zcrypt_api.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c index 4bf36e53fe3e..6fe05bb82c77 100644 --- a/drivers/s390/crypto/zcrypt_api.c +++ b/drivers/s390/crypto/zcrypt_api.c @@ -347,8 +347,7 @@ static ssize_t zcdn_create_store(struct class *class, int rc; char name[ZCDN_MAX_NAME]; - strncpy(name, skip_spaces(buf), sizeof(name)); - name[sizeof(name) - 1] = '\0'; + strscpy(name, skip_spaces(buf), sizeof(name)); rc = zcdn_create(strim(name)); @@ -365,8 +364,7 @@ static ssize_t zcdn_destroy_store(struct class *class, int rc; char name[ZCDN_MAX_NAME]; - strncpy(name, skip_spaces(buf), sizeof(name)); - name[sizeof(name) - 1] = '\0'; + strscpy(name, skip_spaces(buf), sizeof(name)); rc = zcdn_destroy(strim(name)); -- 2.15.2