* [withdrawn] lib-stringc-strlcpy-might-read-too-far.patch removed from -mm tree
@ 2014-04-15 20:46 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2014-04-15 20:46 UTC (permalink / raw)
To: mm-commits, vegard.nossum, dan.carpenter
Subject: [withdrawn] lib-stringc-strlcpy-might-read-too-far.patch removed from -mm tree
To: dan.carpenter@oracle.com,vegard.nossum@gmail.com,mm-commits@vger.kernel.org
From: akpm@linux-foundation.org
Date: Tue, 15 Apr 2014 13:46:01 -0700
The patch titled
Subject: lib/string.c: strlcpy() might read too far
has been removed from the -mm tree. Its filename was
lib-stringc-strlcpy-might-read-too-far.patch
This patch was dropped because it was withdrawn
------------------------------------------------------
From: Dan Carpenter <dan.carpenter@oracle.com>
Subject: lib/string.c: strlcpy() might read too far
Imagine you have a user controlled variable at the end of a struct which
is allocated at the end of a page. The strlen() could read beyond the
mapped memory and cause an oops.
Probably there are two reasons why we have never hit this condition in
real life. First you would have to be really unlucky for all the
variables to line up so the oops can happen. Second we don't do a lot of
fuzzing with invalid strings.
The strnlen() call is obviously a little bit slower than strlen() but I
have tested it and I think it's probably ok.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reported-by: Vegard Nossum <vegard.nossum@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
lib/string.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff -puN lib/string.c~lib-stringc-strlcpy-might-read-too-far lib/string.c
--- a/lib/string.c~lib-stringc-strlcpy-might-read-too-far
+++ a/lib/string.c
@@ -148,10 +148,10 @@ EXPORT_SYMBOL(strncpy);
*/
size_t strlcpy(char *dest, const char *src, size_t size)
{
- size_t ret = strlen(src);
+ size_t ret = strnlen(src, size);
if (size) {
- size_t len = (ret >= size) ? size - 1 : ret;
+ size_t len = (ret < size) ? ret : ret - 1;
memcpy(dest, src, len);
dest[len] = '\0';
}
_
Patches currently in -mm which might be from dan.carpenter@oracle.com are
lib-stringc-use-the-name-c-string-in-comments.patch
linux-next.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-04-15 20:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-15 20:46 [withdrawn] lib-stringc-strlcpy-might-read-too-far.patch removed from -mm tree akpm
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.