Workaround b/16818336 which fails build under aggressive inlining.
(cherry-pick of 7aa27e1c1a53afe28f6180fd1fc50d096cabea7b.)
Change-Id: Ifcd596714c427a2ec39502b9c0af9082ded91884
diff --git a/libc/include/string.h b/libc/include/string.h
index af1c0c1..8df68e3 100644
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -94,9 +94,6 @@
#if defined(__BIONIC_FORTIFY)
-__errordecl(__memcpy_dest_size_error, "memcpy: prevented write past end of buffer");
-__errordecl(__memcpy_src_size_error, "memcpy: prevented read past end of buffer");
-
__BIONIC_FORTIFY_INLINE
void* memcpy(void* __restrict dest, const void* __restrict src, size_t copy_amount) {
char *d = (char *) dest;
@@ -104,14 +101,6 @@
size_t s_len = __bos0(s);
size_t d_len = __bos0(d);
- if (__builtin_constant_p(copy_amount) && (copy_amount > d_len)) {
- __memcpy_dest_size_error();
- }
-
- if (__builtin_constant_p(copy_amount) && (copy_amount > s_len)) {
- __memcpy_src_size_error();
- }
-
return __builtin___memcpy_chk(dest, src, copy_amount, d_len);
}
@@ -130,16 +119,12 @@
return __builtin___strcpy_chk(dest, src, __bos(dest));
}
-__errordecl(__stpncpy_error, "stpncpy: prevented write past end of buffer");
extern char* __stpncpy_chk2(char* __restrict, const char* __restrict, size_t, size_t, size_t);
__BIONIC_FORTIFY_INLINE
char* stpncpy(char* __restrict dest, const char* __restrict src, size_t n) {
size_t bos_dest = __bos(dest);
size_t bos_src = __bos(src);
- if (__builtin_constant_p(n) && (n > bos_dest)) {
- __stpncpy_error();
- }
if (bos_src == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
return __builtin___stpncpy_chk(dest, src, n, bos_dest);
@@ -157,16 +142,12 @@
return __stpncpy_chk2(dest, src, n, bos_dest, bos_src);
}
-__errordecl(__strncpy_error, "strncpy: prevented write past end of buffer");
extern char* __strncpy_chk2(char* __restrict, const char* __restrict, size_t, size_t, size_t);
__BIONIC_FORTIFY_INLINE
char* strncpy(char* __restrict dest, const char* __restrict src, size_t n) {
size_t bos_dest = __bos(dest);
size_t bos_src = __bos(src);
- if (__builtin_constant_p(n) && (n > bos_dest)) {
- __strncpy_error();
- }
if (bos_src == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
return __builtin___strncpy_chk(dest, src, n, bos_dest);
@@ -201,7 +182,6 @@
extern size_t __strlcpy_real(char* __restrict, const char* __restrict, size_t)
__asm__(__USER_LABEL_PREFIX__ "strlcpy");
-__errordecl(__strlcpy_error, "strlcpy: prevented write past end of buffer");
extern size_t __strlcpy_chk(char *, const char *, size_t, size_t);
__BIONIC_FORTIFY_INLINE
@@ -219,12 +199,6 @@
if (__builtin_constant_p(size) && (size <= bos)) {
return __strlcpy_real(dest, src, size);
}
-
- // Compiler can prove, at compile time, that the passed in size
- // is always > the actual object size. Force a compiler error.
- if (__builtin_constant_p(size) && (size > bos)) {
- __strlcpy_error();
- }
#endif /* !defined(__clang__) */
return __strlcpy_chk(dest, src, size, bos);
@@ -232,7 +206,6 @@
extern size_t __strlcat_real(char* __restrict, const char* __restrict, size_t)
__asm__(__USER_LABEL_PREFIX__ "strlcat");
-__errordecl(__strlcat_error, "strlcat: prevented write past end of buffer");
extern size_t __strlcat_chk(char* __restrict, const char* __restrict, size_t, size_t);
@@ -251,12 +224,6 @@
if (__builtin_constant_p(size) && (size <= bos)) {
return __strlcat_real(dest, src, size);
}
-
- // Compiler can prove, at compile time, that the passed in size
- // is always > the actual object size. Force a compiler error.
- if (__builtin_constant_p(size) && (size > bos)) {
- __strlcat_error();
- }
#endif /* !defined(__clang__) */
return __strlcat_chk(dest, src, size, bos);