2023-01-03 02:24:34

by Yang Yang

[permalink] [raw]
Subject: [PATCH linux-next v2] s390/zcrypt: use strscpy() to instead of strncpy()

From: Yang Yang <[email protected]>

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 <[email protected]>
Signed-off-by: Xu Panda <[email protected]>
---
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


2023-01-03 10:22:21

by Heiko Carstens

[permalink] [raw]
Subject: Re: [PATCH linux-next v2] s390/zcrypt: use strscpy() to instead of strncpy()

On Tue, Jan 03, 2023 at 10:02:07AM +0800, [email protected] wrote:
> From: Yang Yang <[email protected]>
>
> 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 <[email protected]>
> Signed-off-by: Xu Panda <[email protected]>
> ---
> chang for v2
> - match the FROM with the Email

You sent this from [email protected], but the sign-off is without the
".cn" suffix. Can you please make sure that your sign-off chain actually
follows the rules as outlined in Documentation/process/submitting-patches.rst?

If you read that then the sign-off line from Xu Panda shouldn't be there,
since the patch was not authored or routed via Xu Panda.

2023-01-05 14:19:03

by Bagas Sanjaya

[permalink] [raw]
Subject: Re: [PATCH linux-next v2] s390/zcrypt: use strscpy() to instead of strncpy()

On Tue, Jan 03, 2023 at 10:51:21AM +0100, Heiko Carstens wrote:
> On Tue, Jan 03, 2023 at 10:02:07AM +0800, [email protected] wrote:
> > From: Yang Yang <[email protected]>
> >
> > 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 <[email protected]>
> > Signed-off-by: Xu Panda <[email protected]>
> > ---
> > chang for v2
> > - match the FROM with the Email
>
> You sent this from [email protected], but the sign-off is without the
> ".cn" suffix. Can you please make sure that your sign-off chain actually
> follows the rules as outlined in Documentation/process/submitting-patches.rst?
>
> If you read that then the sign-off line from Xu Panda shouldn't be there,
> since the patch was not authored or routed via Xu Panda.

Specifically, the second SoB from Xu should only be included if he was
in From: mail header (that is, he should have sent the patch instead of
Yang).

Ah! Thanks for reminding me of this trivial issue that I always missed
when reviewing ZTE patches.

Xu, are you really transporting Yang's patch?

Thanks.

--
An old man doll... just what I always wanted! - Clara


Attachments:
(No filename) (1.23 kB)
signature.asc (235.00 B)
Download all attachments

2023-01-10 04:02:51

by Yang Yang

[permalink] [raw]
Subject: Re: [PATCH linux-next v2] s390/zcrypt: use strscpy() to instead of strncpy()

> Specifically, the second SoB from Xu should only be included if he was>
> in From: mail header (that is, he should have sent the patch instead of>
> Yang).

Thanks to your carefully reviewing! Actually this patch is made by Xu,
and Yang help to send it. I remember this is OK by patch rules. If I am
wrong, I will try to correct it.

Thanks.