diff options
author | Nick Kralevich <nnk@google.com> | 2012-07-13 14:46:36 -0700 |
---|---|---|
committer | Nick Kralevich <nnk@google.com> | 2012-07-13 14:49:33 -0700 |
commit | 9b6cc223a36835c4367a036d4cfeff14d25bc742 (patch) | |
tree | 8fcd143b253225860fbd817cdad02afac00f1be8 | |
parent | 260bf8cfe00f83bc579dfe81c78b75bd9973f051 (diff) | |
download | bionic-9b6cc223a36835c4367a036d4cfeff14d25bc742.zip bionic-9b6cc223a36835c4367a036d4cfeff14d25bc742.tar.gz bionic-9b6cc223a36835c4367a036d4cfeff14d25bc742.tar.bz2 |
FORTIFY_SOURCE: introduce __BIONIC_FORTIFY_UNKNOWN_SIZE macro
Replace all occurances of "(size_t) -1" with a
__BIONIC_FORTIFY_UNKNOWN_SIZE macro.
Change-Id: I0b188f6cf31417d2dbef0e1bd759de3f9782873a
-rw-r--r-- | libc/include/stdio.h | 2 | ||||
-rw-r--r-- | libc/include/string.h | 9 | ||||
-rw-r--r-- | libc/include/sys/cdefs.h | 1 |
3 files changed, 8 insertions, 4 deletions
diff --git a/libc/include/stdio.h b/libc/include/stdio.h index c12ddb8..453cf0b 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -547,7 +547,7 @@ char *fgets(char *dest, int size, FILE *stream) } // 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); } diff --git a/libc/include/string.h b/libc/include/string.h index 842aa39..8730ea3 100644 --- a/libc/include/string.h +++ b/libc/include/string.h @@ -166,7 +166,7 @@ size_t strlcpy(char *dest, const char *src, size_t size) { size_t bos = __builtin_object_size(dest, 0); // 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); } @@ -197,7 +197,7 @@ size_t strlcat(char *dest, const char *src, size_t size) { size_t bos = __builtin_object_size(dest, 0); // 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); } @@ -223,9 +223,12 @@ extern size_t __strlen_chk(const char *, size_t); __BIONIC_FORTIFY_INLINE size_t strlen(const char *s) { 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_chk(s, bos); } diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h index 1ba9100..987a5e3 100644 --- a/libc/include/sys/cdefs.h +++ b/libc/include/sys/cdefs.h @@ -507,6 +507,7 @@ __attribute__ ((always_inline)) \ __attribute__ ((gnu_inline)) \ __attribute__ ((artificial)) +#define __BIONIC_FORTIFY_UNKNOWN_SIZE ((size_t) -1) #endif #endif /* !_SYS_CDEFS_H_ */ |