diff options
Diffstat (limited to 'libc/bionic')
-rw-r--r-- | libc/bionic/__fgets_chk.cpp (renamed from libc/bionic/__fgets_chk.c) | 2 | ||||
-rw-r--r-- | libc/bionic/__memcpy_chk.cpp (renamed from libc/bionic/__memcpy_chk.c) | 2 | ||||
-rw-r--r-- | libc/bionic/__memmove_chk.cpp (renamed from libc/bionic/__memmove_chk.c) | 2 | ||||
-rw-r--r-- | libc/bionic/__memset_chk.cpp (renamed from libc/bionic/__memset_chk.c) | 3 | ||||
-rw-r--r-- | libc/bionic/__snprintf_chk.c | 59 | ||||
-rw-r--r-- | libc/bionic/__sprintf_chk.c | 58 | ||||
-rw-r--r-- | libc/bionic/__strcat_chk.cpp (renamed from libc/bionic/__strcat_chk.c) | 3 | ||||
-rw-r--r-- | libc/bionic/__strcpy_chk.cpp (renamed from libc/bionic/__strcpy_chk.c) | 3 | ||||
-rw-r--r-- | libc/bionic/__strlcat_chk.cpp (renamed from libc/bionic/__strlcat_chk.c) | 2 | ||||
-rw-r--r-- | libc/bionic/__strlcpy_chk.cpp (renamed from libc/bionic/__strlcpy_chk.c) | 2 | ||||
-rw-r--r-- | libc/bionic/__strlen_chk.cpp (renamed from libc/bionic/__strlen_chk.c) | 3 | ||||
-rw-r--r-- | libc/bionic/__strncat_chk.cpp (renamed from libc/bionic/__strncat_chk.c) | 2 | ||||
-rw-r--r-- | libc/bionic/__strncpy_chk.cpp (renamed from libc/bionic/__strncpy_chk.c) | 2 | ||||
-rw-r--r-- | libc/bionic/__umask_chk.cpp (renamed from libc/bionic/__umask_chk.c) | 3 | ||||
-rw-r--r-- | libc/bionic/__vsnprintf_chk.cpp (renamed from libc/bionic/__vsnprintf_chk.c) | 33 | ||||
-rw-r--r-- | libc/bionic/__vsprintf_chk.cpp (renamed from libc/bionic/__vsprintf_chk.c) | 32 |
16 files changed, 73 insertions, 138 deletions
diff --git a/libc/bionic/__fgets_chk.c b/libc/bionic/__fgets_chk.cpp index 19123b970..780cf1635 100644 --- a/libc/bionic/__fgets_chk.c +++ b/libc/bionic/__fgets_chk.cpp @@ -41,7 +41,7 @@ * This fgets check is called if _FORTIFY_SOURCE is defined and * greater than 0. */ -char *__fgets_chk(char *dest, int supplied_size, +extern "C" char *__fgets_chk(char *dest, int supplied_size, FILE *stream, size_t dest_len_from_compiler) { if (supplied_size < 0) { diff --git a/libc/bionic/__memcpy_chk.c b/libc/bionic/__memcpy_chk.cpp index 10334bab4..991ff02a4 100644 --- a/libc/bionic/__memcpy_chk.c +++ b/libc/bionic/__memcpy_chk.cpp @@ -42,7 +42,7 @@ * This memcpy check is called if _FORTIFY_SOURCE is defined and * greater than 0. */ -void *__memcpy_chk(void *dest, const void *src, +extern "C" void *__memcpy_chk(void *dest, const void *src, size_t copy_amount, size_t dest_len) { if (__builtin_expect(copy_amount > dest_len, 0)) { diff --git a/libc/bionic/__memmove_chk.c b/libc/bionic/__memmove_chk.cpp index 529eb8fc6..1867d716a 100644 --- a/libc/bionic/__memmove_chk.c +++ b/libc/bionic/__memmove_chk.cpp @@ -41,7 +41,7 @@ * This memmove check is called if _FORTIFY_SOURCE is defined and * greater than 0. */ -void *__memmove_chk (void *dest, const void *src, +extern "C" void *__memmove_chk (void *dest, const void *src, size_t len, size_t dest_len) { if (len > dest_len) { diff --git a/libc/bionic/__memset_chk.c b/libc/bionic/__memset_chk.cpp index 0904c036c..97c5c384a 100644 --- a/libc/bionic/__memset_chk.c +++ b/libc/bionic/__memset_chk.cpp @@ -41,8 +41,7 @@ * This memset check is called if _FORTIFY_SOURCE is defined and * greater than 0. */ -void *__memset_chk (void *dest, int c, size_t n, size_t dest_len) -{ +extern "C" void *__memset_chk (void *dest, int c, size_t n, size_t dest_len) { if (n > dest_len) { __libc_android_log_print(ANDROID_LOG_FATAL, "libc", "*** memset buffer overflow detected ***\n"); diff --git a/libc/bionic/__snprintf_chk.c b/libc/bionic/__snprintf_chk.c deleted file mode 100644 index dbda3db38..000000000 --- a/libc/bionic/__snprintf_chk.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <stdio.h> -#include <stdarg.h> - -/* - * Runtime implementation of __builtin____snprintf_chk. - * - * See - * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html - * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html - * for details. - * - * This snprintf check is called if _FORTIFY_SOURCE is defined and - * greater than 0. - */ -int __snprintf_chk( - char *dest, - size_t supplied_size, - int flags, - size_t dest_len_from_compiler, - const char *format, ...) -{ - va_list va; - int retval; - - va_start(va, format); - retval = __vsnprintf_chk(dest, supplied_size, flags, - dest_len_from_compiler, format, va); - va_end(va); - - return retval; -} diff --git a/libc/bionic/__sprintf_chk.c b/libc/bionic/__sprintf_chk.c deleted file mode 100644 index 67acbe18f..000000000 --- a/libc/bionic/__sprintf_chk.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <stdio.h> -#include <stdarg.h> - -/* - * Runtime implementation of __builtin____sprintf_chk. - * - * See - * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html - * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html - * for details. - * - * This sprintf check is called if _FORTIFY_SOURCE is defined and - * greater than 0. - */ -int __sprintf_chk( - char *dest, - int flags, - size_t dest_len_from_compiler, - const char *format, ...) -{ - va_list va; - int retval; - - va_start(va, format); - retval = __vsprintf_chk(dest, flags, - dest_len_from_compiler, format, va); - va_end(va); - - return retval; -} diff --git a/libc/bionic/__strcat_chk.c b/libc/bionic/__strcat_chk.cpp index 4665d6660..ec194fc18 100644 --- a/libc/bionic/__strcat_chk.c +++ b/libc/bionic/__strcat_chk.cpp @@ -42,8 +42,7 @@ * This strcat check is called if _FORTIFY_SOURCE is defined and * greater than 0. */ -char *__strcat_chk (char *dest, const char *src, size_t dest_buf_size) -{ +extern "C" char *__strcat_chk (char *dest, const char *src, size_t dest_buf_size) { // TODO: optimize so we don't scan src/dest twice. size_t src_len = strlen(src); size_t dest_len = strlen(dest); diff --git a/libc/bionic/__strcpy_chk.c b/libc/bionic/__strcpy_chk.cpp index 79486b40c..1d45ea27b 100644 --- a/libc/bionic/__strcpy_chk.c +++ b/libc/bionic/__strcpy_chk.cpp @@ -41,8 +41,7 @@ * This strcpy check is called if _FORTIFY_SOURCE is defined and * greater than 0. */ -char *__strcpy_chk (char *dest, const char *src, size_t dest_len) -{ +extern "C" char *__strcpy_chk (char *dest, const char *src, size_t dest_len) { // TODO: optimize so we don't scan src twice. size_t src_len = strlen(src) + 1; if (src_len > dest_len) { diff --git a/libc/bionic/__strlcat_chk.c b/libc/bionic/__strlcat_chk.cpp index b895fb886..05b7d7d50 100644 --- a/libc/bionic/__strlcat_chk.c +++ b/libc/bionic/__strlcat_chk.cpp @@ -42,7 +42,7 @@ * This strlcat check is called if _FORTIFY_SOURCE is defined and * greater than 0. */ -size_t __strlcat_chk(char *dest, const char *src, +extern "C" size_t __strlcat_chk(char *dest, const char *src, size_t supplied_size, size_t dest_len_from_compiler) { if (supplied_size > dest_len_from_compiler) { diff --git a/libc/bionic/__strlcpy_chk.c b/libc/bionic/__strlcpy_chk.cpp index 752c86ca0..bf9803781 100644 --- a/libc/bionic/__strlcpy_chk.c +++ b/libc/bionic/__strlcpy_chk.cpp @@ -42,7 +42,7 @@ * This strlcpy check is called if _FORTIFY_SOURCE is defined and * greater than 0. */ -size_t __strlcpy_chk(char *dest, const char *src, +extern "C" size_t __strlcpy_chk(char *dest, const char *src, size_t supplied_size, size_t dest_len_from_compiler) { if (supplied_size > dest_len_from_compiler) { diff --git a/libc/bionic/__strlen_chk.c b/libc/bionic/__strlen_chk.cpp index 43e7e80e8..67410d42c 100644 --- a/libc/bionic/__strlen_chk.c +++ b/libc/bionic/__strlen_chk.cpp @@ -53,8 +53,7 @@ * * or anytime strlen reads beyond an object boundary. */ -size_t __strlen_chk(const char *s, size_t s_len) -{ +extern "C" size_t __strlen_chk(const char *s, size_t s_len) { size_t ret = strlen(s); if (__builtin_expect(ret >= s_len, 0)) { diff --git a/libc/bionic/__strncat_chk.c b/libc/bionic/__strncat_chk.cpp index 2036c9f17..2ba855034 100644 --- a/libc/bionic/__strncat_chk.c +++ b/libc/bionic/__strncat_chk.cpp @@ -42,7 +42,7 @@ * This strncat check is called if _FORTIFY_SOURCE is defined and * greater than 0. */ -char *__strncat_chk (char *dest, const char *src, +extern "C" char *__strncat_chk (char *dest, const char *src, size_t len, size_t dest_buf_size) { // TODO: optimize so we don't scan src/dest twice. diff --git a/libc/bionic/__strncpy_chk.c b/libc/bionic/__strncpy_chk.cpp index 3f9e9fb5a..875d092f0 100644 --- a/libc/bionic/__strncpy_chk.c +++ b/libc/bionic/__strncpy_chk.cpp @@ -41,7 +41,7 @@ * This strncpy check is called if _FORTIFY_SOURCE is defined and * greater than 0. */ -char *__strncpy_chk (char *dest, const char *src, +extern "C" char *__strncpy_chk (char *dest, const char *src, size_t len, size_t dest_len) { if (len > dest_len) { diff --git a/libc/bionic/__umask_chk.c b/libc/bionic/__umask_chk.cpp index 5bb6a3b2f..df066b213 100644 --- a/libc/bionic/__umask_chk.c +++ b/libc/bionic/__umask_chk.cpp @@ -41,8 +41,7 @@ * This umask check is called if _FORTIFY_SOURCE is defined and * greater than 0. */ -mode_t __umask_chk(mode_t mode) -{ +extern "C" mode_t __umask_chk(mode_t mode) { if ((mode & 0777) != mode) { __libc_android_log_print(ANDROID_LOG_FATAL, "libc", "*** FORTIFY_SOURCE: umask called with invalid mask ***\n"); diff --git a/libc/bionic/__vsnprintf_chk.c b/libc/bionic/__vsnprintf_chk.cpp index a1a103920..b4f534bc3 100644 --- a/libc/bionic/__vsnprintf_chk.c +++ b/libc/bionic/__vsnprintf_chk.cpp @@ -42,10 +42,10 @@ * This vsnprintf check is called if _FORTIFY_SOURCE is defined and * greater than 0. */ -int __vsnprintf_chk( +extern "C" int __vsnprintf_chk( char *dest, size_t supplied_size, - int flags, + int /*flags*/, size_t dest_len_from_compiler, const char *format, va_list va) @@ -58,3 +58,32 @@ int __vsnprintf_chk( return vsnprintf(dest, supplied_size, format, va); } + +/* + * Runtime implementation of __builtin____snprintf_chk. + * + * See + * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html + * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html + * for details. + * + * This snprintf check is called if _FORTIFY_SOURCE is defined and + * greater than 0. + */ +extern "C" int __snprintf_chk( + char *dest, + size_t supplied_size, + int flags, + size_t dest_len_from_compiler, + const char *format, ...) +{ + va_list va; + int retval; + + va_start(va, format); + retval = __vsnprintf_chk(dest, supplied_size, flags, + dest_len_from_compiler, format, va); + va_end(va); + + return retval; +} diff --git a/libc/bionic/__vsprintf_chk.c b/libc/bionic/__vsprintf_chk.cpp index 8a809fc6d..00010cfca 100644 --- a/libc/bionic/__vsprintf_chk.c +++ b/libc/bionic/__vsprintf_chk.cpp @@ -42,9 +42,9 @@ * This vsprintf check is called if _FORTIFY_SOURCE is defined and * greater than 0. */ -int __vsprintf_chk( +extern "C" int __vsprintf_chk( char *dest, - int flags, + int /*flags*/, size_t dest_len_from_compiler, const char *format, va_list va) @@ -59,3 +59,31 @@ int __vsprintf_chk( return ret; } + +/* + * Runtime implementation of __builtin____sprintf_chk. + * + * See + * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html + * http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html + * for details. + * + * This sprintf check is called if _FORTIFY_SOURCE is defined and + * greater than 0. + */ +extern "C" int __sprintf_chk( + char *dest, + int flags, + size_t dest_len_from_compiler, + const char *format, ...) +{ + va_list va; + int retval; + + va_start(va, format); + retval = __vsprintf_chk(dest, flags, + dest_len_from_compiler, format, va); + va_end(va); + + return retval; +} |