FORTIFY_SOURCE: revert memcpy changes.

Performance regressions.  Hopefully this is a temporary
rollback.

Bug: 6821003
Change-Id: I84abbb89e1739d506b583f2f1668f31534127764
This commit is contained in:
Nick Kralevich
2012-07-13 17:49:10 -07:00
parent e1d909f71e
commit c37fc1ab6a
2 changed files with 4 additions and 38 deletions

View File

@@ -32,7 +32,7 @@
#include <private/logd.h>
/*
* Runtime implementation of __memcpy_chk2.
* Runtime implementation of __memcpy_chk.
*
* See
* http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
@@ -42,12 +42,9 @@
* This memcpy check is called if _FORTIFY_SOURCE is defined and
* greater than 0.
*/
void *__memcpy_chk2(void *dest, const void *src,
size_t copy_amount, size_t dest_len, size_t src_len)
void *__memcpy_chk(void *dest, const void *src,
size_t copy_amount, size_t dest_len)
{
char *d = (char *) dest;
const char *s = (const char *) src;
if (__builtin_expect(copy_amount > dest_len, 0)) {
__libc_android_log_print(ANDROID_LOG_FATAL, "libc",
"*** memcpy buffer overflow detected ***\n");
@@ -55,28 +52,5 @@ void *__memcpy_chk2(void *dest, const void *src,
abort();
}
if (__builtin_expect(copy_amount > src_len, 0)) {
__libc_android_log_print(ANDROID_LOG_FATAL, "libc",
"*** memcpy read overflow detected ***\n");
abort();
}
if (__builtin_expect(((d <= s) && ((size_t)(s - d) < copy_amount))
|| ((d >= s) && ((size_t)(d - s) < copy_amount)), 0)) {
__libc_android_log_print(ANDROID_LOG_FATAL, "libc",
"*** memcpy memory overlap detected ***\n");
abort();
}
return memcpy(dest, src, copy_amount);
}
/*
* GCC can create references to __memcpy_chk when using
* __builtin__memmove_chk().
*/
void *__memcpy_chk(void *dest, const void *src,
size_t copy_amount, size_t dest_len)
{
return __memcpy_chk2(dest, src, copy_amount, dest_len, (size_t) -1);
}