Merge "FORTIFY_SOURCE: introduce __BIONIC_FORTIFY_UNKNOWN_SIZE macro"

This commit is contained in:
Nick Kralevich 2012-07-13 15:06:56 -07:00 committed by android code review
commit e1d909f71e
3 changed files with 8 additions and 4 deletions
libc/include

@ -547,7 +547,7 @@ char *fgets(char *dest, int size, FILE *stream)
} }
// Compiler doesn't know destination size. Don't call __fgets_chk // Compiler doesn't know destination size. Don't call __fgets_chk
if (bos == (size_t) -1) { if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
return __fgets_real(dest, size, stream); return __fgets_real(dest, size, stream);
} }

@ -166,7 +166,7 @@ size_t strlcpy(char *dest, const char *src, size_t size) {
size_t bos = __builtin_object_size(dest, 0); size_t bos = __builtin_object_size(dest, 0);
// Compiler doesn't know destination size. Don't call __strlcpy_chk // Compiler doesn't know destination size. Don't call __strlcpy_chk
if (bos == (size_t) -1) { if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
return __strlcpy_real(dest, src, size); return __strlcpy_real(dest, src, size);
} }
@ -197,7 +197,7 @@ size_t strlcat(char *dest, const char *src, size_t size) {
size_t bos = __builtin_object_size(dest, 0); size_t bos = __builtin_object_size(dest, 0);
// Compiler doesn't know destination size. Don't call __strlcat_chk // Compiler doesn't know destination size. Don't call __strlcat_chk
if (bos == (size_t) -1) { if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
return __strlcat_real(dest, src, size); return __strlcat_real(dest, src, size);
} }
@ -223,9 +223,12 @@ extern size_t __strlen_chk(const char *, size_t);
__BIONIC_FORTIFY_INLINE __BIONIC_FORTIFY_INLINE
size_t strlen(const char *s) { size_t strlen(const char *s) {
size_t bos = __builtin_object_size(s, 0); size_t bos = __builtin_object_size(s, 0);
if (bos == (size_t) -1) {
// Compiler doesn't know destination size. Don't call __strlen_chk
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
return __strlen_real(s); return __strlen_real(s);
} }
return __strlen_chk(s, bos); return __strlen_chk(s, bos);
} }

@ -507,6 +507,7 @@
__attribute__ ((always_inline)) \ __attribute__ ((always_inline)) \
__attribute__ ((gnu_inline)) \ __attribute__ ((gnu_inline)) \
__attribute__ ((artificial)) __attribute__ ((artificial))
#define __BIONIC_FORTIFY_UNKNOWN_SIZE ((size_t) -1)
#endif #endif
#endif /* !_SYS_CDEFS_H_ */ #endif /* !_SYS_CDEFS_H_ */