Merge "FORTIFY_SOURCE: emphasize prevention in error messages."
This commit is contained in:
commit
bf452313b0
16 changed files with 18 additions and 18 deletions
|
@ -49,7 +49,7 @@ extern "C" char *__fgets_chk(char *dest, int supplied_size,
|
|||
}
|
||||
|
||||
if (((size_t) supplied_size) > dest_len_from_compiler) {
|
||||
__fortify_chk_fail("fgets buffer overflow", 0);
|
||||
__fortify_chk_fail("fgets buffer overflow prevented", 0);
|
||||
}
|
||||
|
||||
return fgets(dest, supplied_size, stream);
|
||||
|
|
|
@ -46,7 +46,7 @@ extern "C" void *__memcpy_chk(void *dest, const void *src,
|
|||
size_t copy_amount, size_t dest_len)
|
||||
{
|
||||
if (__predict_false(copy_amount > dest_len)) {
|
||||
__fortify_chk_fail("memcpy buffer overflow",
|
||||
__fortify_chk_fail("memcpy buffer overflow prevented",
|
||||
BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ extern "C" void *__memmove_chk (void *dest, const void *src,
|
|||
size_t len, size_t dest_len)
|
||||
{
|
||||
if (__predict_false(len > dest_len)) {
|
||||
__fortify_chk_fail("memmove buffer overflow",
|
||||
__fortify_chk_fail("memmove buffer overflow prevented",
|
||||
BIONIC_EVENT_MEMMOVE_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
*/
|
||||
extern "C" void *__memset_chk (void *dest, int c, size_t n, size_t dest_len) {
|
||||
if (__predict_false(n > dest_len)) {
|
||||
__fortify_chk_fail("memset buffer overflow",
|
||||
__fortify_chk_fail("memset buffer overflow prevented",
|
||||
BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ ssize_t __recvfrom_chk(int socket, void* buf, size_t len, size_t buflen, unsigne
|
|||
const struct sockaddr* src_addr, socklen_t* addrlen)
|
||||
{
|
||||
if (__predict_false(len > buflen)) {
|
||||
__fortify_chk_fail("recvfrom overflow", 0);
|
||||
__fortify_chk_fail("recvfrom buffer overflow prevented", 0);
|
||||
}
|
||||
|
||||
return recvfrom(socket, buf, len, flags, src_addr, addrlen);
|
||||
|
|
|
@ -55,7 +55,7 @@ extern "C" char* __strcat_chk(
|
|||
while ((*dest++ = *src++) != '\0') {
|
||||
dest_buf_size--;
|
||||
if (__predict_false(dest_buf_size == 0)) {
|
||||
__fortify_chk_fail("strcat buffer overflow",
|
||||
__fortify_chk_fail("strcat buffer overflow prevented",
|
||||
BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
extern "C" char* __strchr_chk(const char* p, int ch, size_t s_len) {
|
||||
for (;; ++p, s_len--) {
|
||||
if (__predict_false(s_len == 0)) {
|
||||
__fortify_chk_fail("read beyond buffer", 0);
|
||||
__fortify_chk_fail("strchr buffer overrun prevented", 0);
|
||||
}
|
||||
if (*p == static_cast<char>(ch)) {
|
||||
return const_cast<char*>(p);
|
||||
|
|
|
@ -45,7 +45,7 @@ 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 (__predict_false(src_len > dest_len)) {
|
||||
__fortify_chk_fail("strcpy buffer overflow",
|
||||
__fortify_chk_fail("strcpy buffer overflow prevented",
|
||||
BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ extern "C" size_t __strlcat_chk(char *dest, const char *src,
|
|||
size_t supplied_size, size_t dest_len_from_compiler)
|
||||
{
|
||||
if (__predict_false(supplied_size > dest_len_from_compiler)) {
|
||||
__fortify_chk_fail("strlcat buffer overflow", 0);
|
||||
__fortify_chk_fail("strlcat buffer overflow prevented", 0);
|
||||
}
|
||||
|
||||
return strlcat(dest, src, supplied_size);
|
||||
|
|
|
@ -46,7 +46,7 @@ extern "C" size_t __strlcpy_chk(char *dest, const char *src,
|
|||
size_t supplied_size, size_t dest_len_from_compiler)
|
||||
{
|
||||
if (__predict_false(supplied_size > dest_len_from_compiler)) {
|
||||
__fortify_chk_fail("strlcpy buffer overflow", 0);
|
||||
__fortify_chk_fail("strlcpy buffer overflow prevented", 0);
|
||||
}
|
||||
|
||||
return strlcpy(dest, src, supplied_size);
|
||||
|
|
|
@ -57,7 +57,7 @@ extern "C" size_t __strlen_chk(const char *s, size_t s_len) {
|
|||
size_t ret = strlen(s);
|
||||
|
||||
if (__predict_false(ret >= s_len)) {
|
||||
__fortify_chk_fail("strlen read overflow", 0);
|
||||
__fortify_chk_fail("strlen buffer overrun prevented", 0);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -59,7 +59,7 @@ extern "C" char *__strncat_chk(
|
|||
len--; dest_buf_size--;
|
||||
|
||||
if (__predict_false(dest_buf_size == 0)) {
|
||||
__fortify_chk_fail("strncat buffer overflow",
|
||||
__fortify_chk_fail("strncat buffer overflow prevented",
|
||||
BIONIC_EVENT_STRNCAT_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ extern "C" char* __strncpy_chk(char* __restrict dest, const char* __restrict src
|
|||
size_t len, size_t dest_len)
|
||||
{
|
||||
if (__predict_false(len > dest_len)) {
|
||||
__fortify_chk_fail("strncpy dest buffer overflow",
|
||||
__fortify_chk_fail("strncpy dest buffer overflow prevented",
|
||||
BIONIC_EVENT_STRNCPY_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ extern "C" char* __strncpy_chk2(char* __restrict dst, const char* __restrict src
|
|||
size_t n, size_t dest_len, size_t src_len)
|
||||
{
|
||||
if (__predict_false(n > dest_len)) {
|
||||
__fortify_chk_fail("strncpy dest buffer overflow",
|
||||
__fortify_chk_fail("strncpy dest buffer overflow prevented",
|
||||
BIONIC_EVENT_STRNCPY_BUFFER_OVERFLOW);
|
||||
}
|
||||
if (n != 0) {
|
||||
|
@ -83,7 +83,7 @@ extern "C" char* __strncpy_chk2(char* __restrict dst, const char* __restrict src
|
|||
|
||||
size_t s_copy_len = static_cast<size_t>(s - src);
|
||||
if (__predict_false(s_copy_len > src_len)) {
|
||||
__fortify_chk_fail("strncpy read beyond end of src buffer", 0);
|
||||
__fortify_chk_fail("strncpy buffer overrun prevented", 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ extern "C" char* __strrchr_chk(const char *p, int ch, size_t s_len)
|
|||
|
||||
for (save = NULL;; ++p, s_len--) {
|
||||
if (s_len == 0)
|
||||
__fortify_chk_fail("strrchr read beyond buffer", 0);
|
||||
__fortify_chk_fail("strrchr read overrun prevented", 0);
|
||||
if (*p == (char) ch)
|
||||
save = (char *)p;
|
||||
if (!*p)
|
||||
|
|
|
@ -51,7 +51,7 @@ extern "C" int __vsnprintf_chk(
|
|||
va_list va)
|
||||
{
|
||||
if (__predict_false(supplied_size > dest_len_from_compiler)) {
|
||||
__fortify_chk_fail("vsnprintf buffer overflow", 0);
|
||||
__fortify_chk_fail("vsnprintf buffer overflow prevented", 0);
|
||||
}
|
||||
|
||||
return vsnprintf(dest, supplied_size, format, va);
|
||||
|
|
|
@ -52,7 +52,7 @@ extern "C" int __vsprintf_chk(
|
|||
int ret = vsnprintf(dest, dest_len_from_compiler, format, va);
|
||||
|
||||
if ((size_t) ret >= dest_len_from_compiler) {
|
||||
__fortify_chk_fail("vsprintf buffer overflow", 0);
|
||||
__fortify_chk_fail("vsprintf buffer overflow prevented", 0);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue