asus-laptop: prefer strscpy() over strcpy()
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 asus-laptop: prefer strscpy() over strcpy()
The function strcpy() is depreciated and potentially unsafe. It performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. The safe replacement is strscpy() [1].
this fixes checkpatch warning:
WARNING: Prefer strscpy over strcpy
--- drivers/platform/x86/asus-laptop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/asus-laptop.c +2 -2
@@ -1832,8 +1832,8 @@ static int asus_acpi_add(struct acpi_device *device)if (!asus)return -ENOMEM ; asus->handle = device->handle; -strcpy (acpi_device_name (device),ASUS_LAPTOP_DEVICE_NAME ); -strcpy (acpi_device_class (device),ASUS_LAPTOP_CLASS ); +strscpy (acpi_device_name (device),ASUS_LAPTOP_DEVICE_NAME ); +strscpy (acpi_device_class (device),ASUS_LAPTOP_CLASS ); device->driver_data = asus; asus->device = device;
Signature · 1 line
2.43.0
Quoted 33 lines · Abdul Rahim
The function
strcpy()is depreciated and potentially unsafe. It performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. The safe replacement isstrscpy()[1].this fixes checkpatch warning:
WARNING: Prefer strscpy over strcpySigned-off-by Abdul Rahim <[email protected]>--- drivers/platform/x86/asus-laptop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/platform/x86/asus-laptop.c +2
-2@@ -1832,8 +1832,8 @@ static int asus_acpi_add(struct acpi_device *device)if (!asus)return -ENOMEM ; asus->handle = device->handle; -strcpy (acpi_device_name (device),ASUS_LAPTOP_DEVICE_NAME ); -strcpy (acpi_device_class (device),ASUS_LAPTOP_CLASS ); +strscpy (acpi_device_name (device),ASUS_LAPTOP_DEVICE_NAME ); +strscpy (acpi_device_class (device),ASUS_LAPTOP_CLASS ); device->driver_data = asus; asus->device = device;Signature · 2 lines
-- 2.43.0
Looks good, thank you for doing this.
Hi,
Quoted 10 lines · Abdul Rahim
The function
strcpy()is depreciated and potentially unsafe. It performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. The safe replacement isstrscpy()[1].this fixes checkpatch warning:
WARNING: Prefer strscpy over strcpy
Thanks, patch looks good to me:
Regards,
Hans
Quoted 19 lines
--- drivers/platform/x86/asus-laptop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/platform/x86/asus-laptop.c +2
-2@@ -1832,8 +1832,8 @@ static int asus_acpi_add(struct acpi_device *device)if (!asus)return -ENOMEM ; asus->handle = device->handle; -strcpy (acpi_device_name (device),ASUS_LAPTOP_DEVICE_NAME ); -strcpy (acpi_device_class (device),ASUS_LAPTOP_CLASS ); +strscpy (acpi_device_name (device),ASUS_LAPTOP_DEVICE_NAME ); +strscpy (acpi_device_class (device),ASUS_LAPTOP_CLASS ); device->driver_data = asus; asus->device = device;
Ilpo Järvinen
maintainerQuoted 9 lines · Abdul Rahim
The function
strcpy()is depreciated and potentially unsafe. It performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. The safe replacement isstrscpy()[1].this fixes checkpatch warning:
WARNING: Prefer strscpy over strcpy[...]
Thank you for your contribution, it has been applied to my local review-ilpo branch. Note it will show up in the public platform-drivers-x86/review-ilpo branch only once I've pushed my local branch there, which might take a while.
The list of commits applied:
[1/1] asus-laptop: prefer strscpy() over strcpy()
commit: 8150408bfdb2f9c17970295427cf91470189e6d0
--
i.