Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp1311rwj; Thu, 22 Dec 2022 19:29:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXtJWaTe8kjgjTa+6+qqMEkNmyDuzkUUBGajkI/UvBkj7BPWowwJhOGUjjkRCUu27FXvBxGj X-Received: by 2002:a17:90a:6608:b0:221:4b1c:3bac with SMTP id l8-20020a17090a660800b002214b1c3bacmr9111713pjj.38.1671766196933; Thu, 22 Dec 2022 19:29:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671766196; cv=none; d=google.com; s=arc-20160816; b=Msk3SfE9QSmF0EpaNtDR6T92ibLQnftNPzHxE5nbVc8km0dxz0YrGLGbPw/+gbtGBM ZKP829ZL50MdfGjEt163ljVDq+YoSD/xwVId0z+TR7XVf3kMMIV80DVymbWJG2+AhCqO Db7RJs9thslskAf6Vk5tMH2pIYGLUGqf/qoDjg04M5NrrQu2rF3hB3qV7q+S19Gh24kO NvjlCNjgVxHXypZbjlaUknZ6sATnx1CKdjO8lHXuHMgL7ZYUVrbMklNjRmdwkyOpR+Sm upEOxVax7wdu5BwJgcdO/bydKJgjMNuLZUK+agX8G2ifC4la9HesRzd9cedUNsO18gV0 Ld+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=+HQfhpp3KZLZWd+Ha+getnT5DTHA93KmqGxCqhEttGA=; b=kjJHvZ3STzhHvssFP+YEzox+VMBCHctknHPfD2+qlm2ACZMQsdVooPeldNhc9IHyDC PxJ+Lf87mSDa6gv0xCP2jkeu1HmT96o4rjoLQF3p3RD9BHpT2Wn4P5pQ5k9v536bhC3w aWNcjkYXT5VwhqpvkKD9MlDuS2qvtX720knUmkcmbmph/dahyc/IjwaHAS+rjkqSxO0Z a73Ll6DP1+9zBa14aevvoQomhi3uESScsDhKeohNU2cMofsY70AXaYXEWRJDqAXbXHOA GNwl7mJMz6gt96fL2TehmCIdNbMlESgcYQ4M3LiIPqptp5YNcOlvynvQkkJIkF0BBAWH haIw== 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 hi20-20020a17090b30d400b00219bd0f8ee3si2272395pjb.40.2022.12.22.19.29.36; Thu, 22 Dec 2022 19:29:56 -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 S230010AbiLWCp3 (ORCPT + 67 others); Thu, 22 Dec 2022 21:45:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235788AbiLWCp1 (ORCPT ); Thu, 22 Dec 2022 21:45:27 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B3CD1F636; Thu, 22 Dec 2022 18:45:26 -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 4NdWkY0ZPNz4xVnH; Fri, 23 Dec 2022 10:45:25 +0800 (CST) Received: from szxlzmapp06.zte.com.cn ([10.5.230.252]) by mse-fl2.zte.com.cn with SMTP id 2BN2jKLi054716; Fri, 23 Dec 2022 10:45:20 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp02[null]) by mapi (Zmail) with MAPI id mid14; Fri, 23 Dec 2022 10:45:21 +0800 (CST) Date: Fri, 23 Dec 2022 10:45:21 +0800 (CST) X-Zmail-TransId: 2b0463a5164112d9a219 X-Mailer: Zmail v1.0 Message-ID: <202212231045217042473@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIHMzOTAvemNyeXB0OiB1c2Ugc3Ryc2NweSgpIHRvIGluc3RlYWQgb2Ygc3RybmNweSgp?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl2.zte.com.cn 2BN2jKLi054716 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 63A51645.001 by FangMail milter! X-FangMail-Envelope: 1671763525/4NdWkY0ZPNz4xVnH/63A51645.001/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63A51645.001/4NdWkY0ZPNz4xVnH 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 --- 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