Merge "libc: upgrade some libc functions to _FORTIFY_SOURCE=2"
diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index fddad2f..31e9261 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -466,8 +466,7 @@
__attribute__((__nonnull__ (3)))
int vsnprintf(char *dest, size_t size, const char *format, __va_list ap)
{
- return __builtin___vsnprintf_chk(dest, size, 0,
- __builtin_object_size(dest, 0), format, ap);
+ return __builtin___vsnprintf_chk(dest, size, 0, __bos(dest), format, ap);
}
__BIONIC_FORTIFY_INLINE
@@ -475,8 +474,7 @@
__attribute__((__nonnull__ (2)))
int vsprintf(char *dest, const char *format, __va_list ap)
{
- return __builtin___vsprintf_chk(dest, 0,
- __builtin_object_size(dest, 0), format, ap);
+ return __builtin___vsprintf_chk(dest, 0, __bos(dest), format, ap);
}
__BIONIC_FORTIFY_INLINE
@@ -485,7 +483,7 @@
int snprintf(char *str, size_t size, const char *format, ...)
{
return __builtin___snprintf_chk(str, size, 0,
- __builtin_object_size(str, 0), format, __builtin_va_arg_pack());
+ __bos(str), format, __builtin_va_arg_pack());
}
__BIONIC_FORTIFY_INLINE
@@ -508,7 +506,7 @@
__BIONIC_FORTIFY_INLINE
char *fgets(char *dest, int size, FILE *stream)
{
- size_t bos = __builtin_object_size(dest, 0);
+ size_t bos = __bos(dest);
// Compiler can prove, at compile time, that the passed in size
// is always negative. Force a compiler error.
diff --git a/libc/include/string.h b/libc/include/string.h
index 02d8151..c0df686 100644
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -116,7 +116,7 @@
__BIONIC_FORTIFY_INLINE
char *strcpy(char *dest, const char *src) {
- return __builtin___strcpy_chk(dest, src, __builtin_object_size (dest, 0));
+ return __builtin___strcpy_chk(dest, src, __bos(dest));
}
extern void __strncpy_error()
@@ -133,12 +133,12 @@
__BIONIC_FORTIFY_INLINE
char *strcat(char *dest, const char *src) {
- return __builtin___strcat_chk(dest, src, __builtin_object_size (dest, 0));
+ return __builtin___strcat_chk(dest, src, __bos(dest));
}
__BIONIC_FORTIFY_INLINE
char *strncat(char *dest, const char *src, size_t n) {
- return __builtin___strncat_chk(dest, src, n, __builtin_object_size (dest, 0));
+ return __builtin___strncat_chk(dest, src, n, __bos(dest));
}
__BIONIC_FORTIFY_INLINE
@@ -154,7 +154,7 @@
__BIONIC_FORTIFY_INLINE
size_t strlcpy(char *dest, const char *src, size_t size) {
- size_t bos = __builtin_object_size(dest, 0);
+ size_t bos = __bos(dest);
// Compiler doesn't know destination size. Don't call __strlcpy_chk
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
@@ -185,7 +185,7 @@
__BIONIC_FORTIFY_INLINE
size_t strlcat(char *dest, const char *src, size_t size) {
- size_t bos = __builtin_object_size(dest, 0);
+ size_t bos = __bos(dest);
// Compiler doesn't know destination size. Don't call __strlcat_chk
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
@@ -211,7 +211,7 @@
__BIONIC_FORTIFY_INLINE
size_t strlen(const char *s) {
- size_t bos = __builtin_object_size(s, 0);
+ size_t bos = __bos(s);
// Compiler doesn't know destination size. Don't call __strlen_chk
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
@@ -230,7 +230,7 @@
__BIONIC_FORTIFY_INLINE
char* strchr(const char *s, int c) {
- size_t bos = __builtin_object_size(s, 0);
+ size_t bos = __bos(s);
// Compiler doesn't know destination size. Don't call __strchr_chk
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {