]> git.karo-electronics.de Git - karo-tx-linux.git/commit
clean up scary strncpy(dst, src, strlen(src)) uses
authorKees Cook <keescook@chromium.org>
Wed, 19 Jun 2013 00:07:06 +0000 (10:07 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 19 Jun 2013 07:26:56 +0000 (17:26 +1000)
commit6eaeb4e222f6d1492eb0c7a4b56f8a68197c1100
treeda8ea51918b01c6a69c4b1a78e576bf6111c62a9
parentb4977a4687c01e3ac3146c6de8d25dcf74ae0482
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.

Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> [staging]
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> [acpi]
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Ursula Braun <ursula.braun@de.ibm.com>
Cc: Frank Blaschka <blaschka@linux.vnet.ibm.com>
Cc: Richard Weinberger <richard@nod.at>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Documentation/accounting/getdelays.c
drivers/acpi/sysfs.c
drivers/s390/net/qeth_l3_sys.c
drivers/staging/tidspbridge/rmgr/drv_interface.c
fs/hppfs/hppfs.c