Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11289536rwl; Mon, 2 Jan 2023 18:24:34 -0800 (PST) X-Google-Smtp-Source: AMrXdXsRgs1PFKT38FrbaWMJyMoSC6upGXXQUA9GlbgMDj3SPPkNcwBoyIPDmFphdNKy5XFBBDSF X-Received: by 2002:a17:906:a1d2:b0:7c0:fd1a:79ef with SMTP id bx18-20020a170906a1d200b007c0fd1a79efmr37096708ejb.48.1672712674735; Mon, 02 Jan 2023 18:24:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672712674; cv=none; d=google.com; s=arc-20160816; b=bPXocYOD/UEqe+/NsqxUIGL3eB7XpSq6Kf+nMw9FO0HCyHdxKPH1/jBKU756CFtyi1 M7XZxQhZnNSzT742cyU9m5G6QPSxdNhDSrH0yj/5I3NlQfgysoKakWkveOR/0ma6w9Bs UglESInk+XK9s5fNDymOE9h3yDJcZMFfRJO5tnL034Z2Pq9TxteDkhCBPdwEPtpUpp7s 44ut25RFbgOhJM2RhQTTtBkH0JgeR49XhhlcwuvoAadXtReqHWnPd31KPX1EZ/xOL8F4 KlvidqDuKUOc0eCyxIbaNFFoxrYk7Or98PWvHu0pOM4pEPEkutuI10rH4PKP5ouzXPbo qQzg== 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=z7GIFGx8coJwxZSySqUn5qa8lppwef73xQW52aSfCvk=; b=VKpZo662AmQ31aQHNt+aTr97une9DiiKOvWEhuxSPnUVtDukQH6VcMNrS3miYcFgxT 6vpjGB8imCG92/jHtVvRExVpziY0N+Jg4lB9lWu4bnb9KyhyfP9+w3HSVcosmf3HtJOn D9ZtqKuvroRaIsTfiPcego6m8ue0hlhpG7cBHcydAWuQQNVHVcmBjE9+qnTxnSE1NHBl 7gb52yQ+GyjmeXw0R2G5K/WrdHvFvx6uLtK9R+HLBJ80/JpRiKysS8568XnMJ8M5TLRe fo7IQn8HvQX7i8Y6Il8EDQlbdn5JTmLYrQthtoAZ+PJPVVu1IsVI7LLwxF5rKk9TOXg9 OQ0g== 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 be1-20020a1709070a4100b007306ac0faa0si27571497ejc.615.2023.01.02.18.24.19; Mon, 02 Jan 2023 18:24:34 -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 S236674AbjACCCm (ORCPT + 63 others); Mon, 2 Jan 2023 21:02:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236336AbjACCCU (ORCPT ); Mon, 2 Jan 2023 21:02:20 -0500 Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 253291039; Mon, 2 Jan 2023 18:02:19 -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 4NmGFj0ylcz501Sr; Tue, 3 Jan 2023 10:02:17 +0800 (CST) Received: from szxlzmapp05.zte.com.cn ([10.5.230.85]) by mse-fl1.zte.com.cn with SMTP id 303226xk053280; Tue, 3 Jan 2023 10:02:06 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp01[null]) by mapi (Zmail) with MAPI id mid14; Tue, 3 Jan 2023 10:02:07 +0800 (CST) Date: Tue, 3 Jan 2023 10:02:07 +0800 (CST) X-Zmail-TransId: 2b0363b38c9f6a036ac0 X-Mailer: Zmail v1.0 Message-ID: <202301031002076571212@zte.com.cn> Mime-Version: 1.0 From: To: , Cc: , , , , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHQgdjJdIHMzOTAvemNyeXB0OiB1c2Ugc3Ryc2NweSgpIHRvIGluc3RlYWQgb2Ygc3RybmNweSgp?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 303226xk053280 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.251.13.novalocal with ID 63B38CA9.001 by FangMail milter! X-FangMail-Envelope: 1672711337/4NmGFj0ylcz501Sr/63B38CA9.001/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63B38CA9.001/4NmGFj0ylcz501Sr 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: Yang Yang The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL-terminated strings. Signed-off-by: Yang Yang Signed-off-by: Xu Panda --- 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