Skip to contentSkip to conversation

s390/zcrypt: use strscpy() to instead of strncpy()

PATCH Superseded [email protected] 3 participants 4 messages Jan 3, 2023 – Jan 10, 2023

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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.

---
chang for v2
- match the FROM with the Email

---
 drivers/s390/crypto/zcrypt_api.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/s390/crypto/zcrypt_api.c +2 -4
index 4bf36e53fe3e..6fe05bb82c77 100644
@@ -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));
 
Signature · 1 line
2.15.2
maintainer
#1 lore raw
Quoted 10 lines · 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.

---
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.

#2 lore raw
Quoted 12 lines · Heiko Carstens
Quoted 10 lines · 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.

---
chang for v2
- match the FROM with the Email

Quoted 6 lines

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.

Signature · 1 line
An old man doll... just what I always wanted! - Clara
#3 lore raw
Quoted 3 lines

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.