Patch "string: provide strscpy()" has been added to the 3.18-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
string: provide strscpy()
to the 3.18-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
string-provide-strscpy.patch
and it can be found in the queue-3.18 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
30035e45753b708e7d47a98398500ca005e02b86Mon Sep 17 00:00:00 2001
From: Chris Metcalf <[email protected]>
Date: Wed, 29 Apr 2015 12:52:04 -0400
Subject: string: provide strscpy()
From: Chris Metcalf <[email protected]>
commit 30035e45753b708e7d47a98398500ca005e02b86 upstream.
The strscpy() API is intended to be used instead of strlcpy(), and instead of most uses of strncpy().
- Unlike strlcpy(), it doesn't read from memory beyond (src + size).
- Unlike strlcpy() or strncpy(), the API provides an easy way to check for destination buffer overflow: an -E2BIG error return value.
- The provided implementation is robust in the face of the source buffer being asynchronously changed during the copy, unlike the current implementation of strlcpy().
- Unlike strncpy(), the destination buffer will be NUL-terminated if the string in the source buffer is too long.
- Also unlike strncpy(), the destination buffer will not be updated beyond the NUL termination, avoiding strncpy's behavior of zeroing the entire tail end of the destination buffer. (A memset() after the strscpy() can be used if this behavior is desired.)
- The implementation should be reasonably performant on all platforms since it uses the asm/word-at-a-time.h API rather than simple byte copy. Kernel-to-kernel string copy is not considered to be performance critical in any case.
--- include/linux/string.h | 3 + lib/string.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+)
include/linux/string.h +3 -0
@@ -25,6 +25,9 @@ extern char * strncpy(char *,const char#ifndef __HAVE_ARCH_STRLCPYsize_t strlcpy (char *,const char *,size_t );#endif +#ifndef __HAVE_ARCH_STRSCPY +ssize_t __must_check strscpy (char *,const char *,size_t ); +#endif #ifndef __HAVE_ARCH_STRCATextern char *strcat (char *,const char *);#endif
lib/string.c +88 -0
100 lines not on this page · raw message
Patches currently in stable-queue which might be from [email protected] are
queue-3.18/strscpy-zero-any-trailing-garbage-bytes-in-the-destination.patch queue-3.18/string-provide-strscpy.patch