Skip to contentSkip to conversation

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

PATCH Applied [email protected] 2 participants 2 messages Jan 5, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

From: Xu Panda <[email protected]>

The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL-terminated strings.

---
chang for v3
- fix the sign-off Email address
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 Applied
#1 lore raw
Quoted 7 lines · On Thu, Jan 05, 2023 at 08:24:34PM +0800, [email protected] wrote:

From: Xu Panda <[email protected]>

The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL-terminated strings.

Quoted 8 lines

---
chang for v3
- fix the sign-off Email address
chang for v2
- match the FROM with the Email

---
 drivers/s390/crypto/zcrypt_api.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Applied, thanks.