public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux-next] s390/zcrypt: use strscpy() to instead of strncpy()
@ 2022-12-23  2:45 yang.yang29
  2023-01-02 12:23 ` Heiko Carstens
  0 siblings, 1 reply; 2+ messages in thread
From: yang.yang29 @ 2022-12-23  2:45 UTC (permalink / raw)
  To: freude
  Cc: hca, gor, agordeev, borntraeger, svens, linux-s390, linux-kernel,
	xu.panda, yang.yang29

From: Xu Panda <xu.panda@zte.com.cn>

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 <xu.panda@zte.com.cn>
Signed-off-by: Yang Yang <yang.yang29@zte.com>
---
 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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH linux-next] s390/zcrypt: use strscpy() to instead of strncpy()
  2022-12-23  2:45 [PATCH linux-next] s390/zcrypt: use strscpy() to instead of strncpy() yang.yang29
@ 2023-01-02 12:23 ` Heiko Carstens
  0 siblings, 0 replies; 2+ messages in thread
From: Heiko Carstens @ 2023-01-02 12:23 UTC (permalink / raw)
  To: yang.yang29
  Cc: freude, gor, agordeev, borntraeger, svens, linux-s390,
	linux-kernel, xu.panda

On Fri, Dec 23, 2022 at 10:45:21AM +0800, yang.yang29@zte.com.cn wrote:
> From: Xu Panda <xu.panda@zte.com.cn>
> 
> 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 <xu.panda@zte.com.cn>
> Signed-off-by: Yang Yang <yang.yang29@zte.com>
> ---
>  drivers/s390/crypto/zcrypt_api.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Please resend and make sure that your Signed-off-by Name+Email address
actually matches the From: field of your Email.

Thank you!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-02 12:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-23  2:45 [PATCH linux-next] s390/zcrypt: use strscpy() to instead of strncpy() yang.yang29
2023-01-02 12:23 ` Heiko Carstens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox