Please sign in to comment.
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. [firstname.lastname@example.org: revert getdelays.c part due to missing bsd/string.h] Signed-off-by: Kees Cook <email@example.com> Acked-by: Greg Kroah-Hartman <firstname.lastname@example.org> [staging] Acked-by: Rafael J. Wysocki <email@example.com> [acpi] Cc: Martin Schwidefsky <firstname.lastname@example.org> Cc: Heiko Carstens <email@example.com> Cc: Ursula Braun <firstname.lastname@example.org> Cc: Frank Blaschka <email@example.com> Cc: Richard Weinberger <firstname.lastname@example.org> Signed-off-by: Andrew Morton <email@example.com> Signed-off-by: Linus Torvalds <firstname.lastname@example.org>
- Loading branch information...
Showing with 10 additions and 13 deletions.