[linux-next,v2] s390/zcrypt: use strscpy() to instead of strncpy()

Message ID 202301031002076571212@zte.com.cn
State New
Headers
Series [linux-next,v2] s390/zcrypt: use strscpy() to instead of strncpy() |

Commit Message

Yang Yang Jan. 3, 2023, 2:02 a.m. UTC
  From: Yang Yang <yang.yang29@zte.com>

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 <yang.yang29@zte.com>
Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
---
chang for v2
 - match the FROM with the Email
---
 drivers/s390/crypto/zcrypt_api.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
  

Comments

Heiko Carstens Jan. 3, 2023, 9:51 a.m. UTC | #1
On Tue, Jan 03, 2023 at 10:02:07AM +0800, yang.yang29@zte.com.cn wrote:
> From: Yang Yang <yang.yang29@zte.com>
> 
> 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 <yang.yang29@zte.com>
> Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
> ---
> chang for v2
>  - match the FROM with the Email

You sent this from yang.yang29@zte.com.cn, 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.
  
Bagas Sanjaya Jan. 5, 2023, 2:01 p.m. UTC | #2
On Tue, Jan 03, 2023 at 10:51:21AM +0100, Heiko Carstens wrote:
> On Tue, Jan 03, 2023 at 10:02:07AM +0800, yang.yang29@zte.com.cn wrote:
> > From: Yang Yang <yang.yang29@zte.com>
> > 
> > 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 <yang.yang29@zte.com>
> > Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
> > ---
> > chang for v2
> >  - match the FROM with the Email
> 
> You sent this from yang.yang29@zte.com.cn, 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.
  
Yang Yang Jan. 10, 2023, 3:16 a.m. UTC | #3
> 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.
  

Patch

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));