mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
clean up scary strncpy(dst, src, strlen(src)) uses
Fix various weird constructions of strncpy(dst, src, strlen(src)). Length limits should be about the space available in the destination, not repurposed as a method to either always include or always exclude a trailing NULL byte. Either the NULL should always be copied (using strlcpy), or it should not be copied (using something like memcpy). Readable code should not depend on the weird behavior of strncpy when it hits the length limit. Better to avoid the anti-pattern entirely. [[email protected]: revert getdelays.c part due to missing bsd/string.h] Signed-off-by: Kees Cook <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> [staging] Acked-by: Rafael J. Wysocki <[email protected]> [acpi] Cc: Martin Schwidefsky <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Ursula Braun <[email protected]> Cc: Frank Blaschka <[email protected]> Cc: Richard Weinberger <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
e7152b97f3
commit
096a8aac6b
4 changed files with 10 additions and 13 deletions
|
|
@ -677,10 +677,9 @@ void acpi_irq_stats_init(void)
|
|||
else
|
||||
sprintf(buffer, "bug%02X", i);
|
||||
|
||||
name = kzalloc(strlen(buffer) + 1, GFP_KERNEL);
|
||||
name = kstrdup(buffer, GFP_KERNEL);
|
||||
if (name == NULL)
|
||||
goto fail;
|
||||
strncpy(name, buffer, strlen(buffer) + 1);
|
||||
|
||||
sysfs_attr_init(&counter_attrs[i].attr);
|
||||
counter_attrs[i].attr.name = name;
|
||||
|
|
|
|||
Loading…
Reference in a new issue