Skip to contentSkip to conversation

vboxfs: use strscpy() is more robust and safer

PATCH In review [email protected] 2 participants 2 messages Nov 22, 2022

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

PATCH 1/1 vboxfs: use strscpy() is more robust and safer

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.

---
 fs/vboxsf/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/vboxsf/super.c +1 -1
index d2f6df69f611..1fb8f4df60cb 100644
@@ -176,7 +176,7 @@ static int vboxsf_fill_super(struct super_block *sb, struct fs_context *fc)
 	}
 	folder_name->size = size;
 	folder_name->length = size - 1;
-	strlcpy(folder_name->string.utf8, fc->source, size);
+	strscpy(folder_name->string.utf8, fc->source, size);
 	err = vboxsf_map_folder(folder_name, &sbi->root);
 	kfree(folder_name);
 	if (err) {
Signature · 1 line
2.15.2
Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 7 lines · On 11/22/22 01:58, [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.

Thanks, patch looks good to me:

Regards,

Hans

Quoted 17 lines
---
 fs/vboxsf/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/vboxsf/super.c +1 -1
index d2f6df69f611..1fb8f4df60cb 100644
@@ -176,7 +176,7 @@ static int vboxsf_fill_super(struct super_block *sb, struct fs_context *fc)
 	}
 	folder_name->size = size;
 	folder_name->length = size - 1;
-	strlcpy(folder_name->string.utf8, fc->source, size);
+	strscpy(folder_name->string.utf8, fc->source, size);
 	err = vboxsf_map_folder(folder_name, &sbi->root);
 	kfree(folder_name);
 	if (err) {