am 76725214
: Merge "Avoid confusing "read prevented write" log messages."
* commit '7672521440c8b7f98795c3fb4295227398e3e296': Avoid confusing "read prevented write" log messages.
This commit is contained in:
commit
264914838d
22 changed files with 187 additions and 237 deletions
|
@ -32,39 +32,39 @@
|
|||
|
||||
extern "C" int __FD_ISSET_chk(int fd, fd_set* set, size_t set_size) {
|
||||
if (__predict_false(fd < 0)) {
|
||||
__fortify_chk_fail("file descriptor is negative for FD_ISSET", 0);
|
||||
__fortify_chk_fail("FD_ISSET: file descriptor < 0", 0);
|
||||
}
|
||||
if (__predict_false(fd >= FD_SETSIZE)) {
|
||||
__fortify_chk_fail("file descriptor is too big for FD_ISSET", 0);
|
||||
__fortify_chk_fail("FD_ISSET: file descriptor >= FD_SETSIZE", 0);
|
||||
}
|
||||
if (__predict_false(set_size < sizeof(fd_set))) {
|
||||
__fortify_chk_fail("set is too small", 0);
|
||||
__fortify_chk_fail("FD_ISSET: set is too small", 0);
|
||||
}
|
||||
return FD_ISSET(fd, set);
|
||||
}
|
||||
|
||||
extern "C" void __FD_CLR_chk(int fd, fd_set* set, size_t set_size) {
|
||||
if (__predict_false(fd < 0)) {
|
||||
__fortify_chk_fail("file descriptor is negative for FD_CLR", 0);
|
||||
__fortify_chk_fail("FD_CLR: file descriptor < 0", 0);
|
||||
}
|
||||
if (__predict_false(fd >= FD_SETSIZE)) {
|
||||
__fortify_chk_fail("file descriptor is too big for FD_CLR", 0);
|
||||
__fortify_chk_fail("FD_CLR: file descriptor >= FD_SETSIZE", 0);
|
||||
}
|
||||
if (__predict_false(set_size < sizeof(fd_set))) {
|
||||
__fortify_chk_fail("set is too small", 0);
|
||||
__fortify_chk_fail("FD_CLR: set is too small", 0);
|
||||
}
|
||||
FD_CLR(fd, set);
|
||||
}
|
||||
|
||||
extern "C" void __FD_SET_chk(int fd, fd_set* set, size_t set_size) {
|
||||
if (__predict_false(fd < 0)) {
|
||||
__fortify_chk_fail("file descriptor is negative for FD_SET", 0);
|
||||
__fortify_chk_fail("FD_SET: file descriptor < 0", 0);
|
||||
}
|
||||
if (__predict_false(fd >= FD_SETSIZE)) {
|
||||
__fortify_chk_fail("file descriptor is too big for FD_SET", 0);
|
||||
__fortify_chk_fail("FD_SET: file descriptor >= FD_SETSIZE", 0);
|
||||
}
|
||||
if (__predict_false(set_size < sizeof(fd_set))) {
|
||||
__fortify_chk_fail("set is too small", 0);
|
||||
__fortify_chk_fail("FD_SET: set is too small", 0);
|
||||
}
|
||||
FD_SET(fd, set);
|
||||
}
|
||||
|
|
|
@ -41,16 +41,15 @@
|
|||
* This fgets check is called if _FORTIFY_SOURCE is defined and
|
||||
* greater than 0.
|
||||
*/
|
||||
extern "C" char *__fgets_chk(char *dest, int supplied_size,
|
||||
FILE *stream, size_t dest_len_from_compiler)
|
||||
{
|
||||
if (supplied_size < 0) {
|
||||
__fortify_chk_fail("fgets buffer size less than 0", 0);
|
||||
}
|
||||
extern "C" char* __fgets_chk(char* dest, int supplied_size,
|
||||
FILE* stream, size_t dest_len_from_compiler) {
|
||||
if (supplied_size < 0) {
|
||||
__fortify_chk_fail("fgets: buffer size < 0", 0);
|
||||
}
|
||||
|
||||
if (((size_t) supplied_size) > dest_len_from_compiler) {
|
||||
__fortify_chk_fail("fgets prevented write past end of buffer", 0);
|
||||
}
|
||||
if (((size_t) supplied_size) > dest_len_from_compiler) {
|
||||
__fortify_chk_fail("fgets: prevented write past end of buffer", 0);
|
||||
}
|
||||
|
||||
return fgets(dest, supplied_size, stream);
|
||||
return fgets(dest, supplied_size, stream);
|
||||
}
|
||||
|
|
|
@ -42,13 +42,12 @@
|
|||
* This memcpy check is called if _FORTIFY_SOURCE is defined and
|
||||
* greater than 0.
|
||||
*/
|
||||
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 prevented write past end of buffer",
|
||||
BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW);
|
||||
}
|
||||
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: prevented write past end of buffer",
|
||||
BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
return memcpy(dest, src, copy_amount);
|
||||
return memcpy(dest, src, copy_amount);
|
||||
}
|
||||
|
|
|
@ -41,13 +41,12 @@
|
|||
* This memmove check is called if _FORTIFY_SOURCE is defined and
|
||||
* greater than 0.
|
||||
*/
|
||||
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 prevented write past end of buffer",
|
||||
BIONIC_EVENT_MEMMOVE_BUFFER_OVERFLOW);
|
||||
}
|
||||
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: prevented write past end of buffer",
|
||||
BIONIC_EVENT_MEMMOVE_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
return memmove(dest, src, len);
|
||||
return memmove(dest, src, len);
|
||||
}
|
||||
|
|
|
@ -41,11 +41,11 @@
|
|||
* This memset check is called if _FORTIFY_SOURCE is defined and
|
||||
* greater than 0.
|
||||
*/
|
||||
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 prevented write past end of buffer",
|
||||
BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW);
|
||||
}
|
||||
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: prevented write past end of buffer",
|
||||
BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
return memset(dest, c, n);
|
||||
return memset(dest, c, n);
|
||||
}
|
||||
|
|
|
@ -32,11 +32,11 @@
|
|||
|
||||
extern "C" ssize_t __read_chk(int fd, void* buf, size_t count, size_t buf_size) {
|
||||
if (__predict_false(count > buf_size)) {
|
||||
__fortify_chk_fail("read prevented write past end of buffer", 0);
|
||||
__fortify_chk_fail("read: prevented write past end of buffer", 0);
|
||||
}
|
||||
|
||||
if (__predict_false(count > SSIZE_MAX)) {
|
||||
__fortify_chk_fail("read count > SSIZE_MAX", 0);
|
||||
__fortify_chk_fail("read: count > SSIZE_MAX", 0);
|
||||
}
|
||||
|
||||
return read(fd, buf, count);
|
||||
|
|
|
@ -34,10 +34,9 @@
|
|||
|
||||
extern "C"
|
||||
ssize_t __recvfrom_chk(int socket, void* buf, size_t len, size_t buflen, unsigned int flags,
|
||||
const struct sockaddr* src_addr, socklen_t* addrlen)
|
||||
{
|
||||
const struct sockaddr* src_addr, socklen_t* addrlen) {
|
||||
if (__predict_false(len > buflen)) {
|
||||
__fortify_chk_fail("recvfrom prevented write past end of buffer", 0);
|
||||
__fortify_chk_fail("recvfrom: prevented write past end of buffer", 0);
|
||||
}
|
||||
|
||||
return recvfrom(socket, buf, len, flags, src_addr, addrlen);
|
||||
|
|
|
@ -41,24 +41,21 @@
|
|||
* This strcat check is called if _FORTIFY_SOURCE is defined and
|
||||
* greater than 0.
|
||||
*/
|
||||
extern "C" char* __strcat_chk(
|
||||
char* __restrict dest,
|
||||
const char* __restrict src,
|
||||
size_t dest_buf_size)
|
||||
{
|
||||
char* save = dest;
|
||||
size_t dest_len = __strlen_chk(dest, dest_buf_size);
|
||||
extern "C" char* __strcat_chk(char* __restrict dest, const char* __restrict src,
|
||||
size_t dest_buf_size) {
|
||||
char* save = dest;
|
||||
size_t dest_len = __strlen_chk(dest, dest_buf_size);
|
||||
|
||||
dest += dest_len;
|
||||
dest_buf_size -= dest_len;
|
||||
dest += dest_len;
|
||||
dest_buf_size -= dest_len;
|
||||
|
||||
while ((*dest++ = *src++) != '\0') {
|
||||
dest_buf_size--;
|
||||
if (__predict_false(dest_buf_size == 0)) {
|
||||
__fortify_chk_fail("strcat prevented write past end of buffer",
|
||||
BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW);
|
||||
}
|
||||
while ((*dest++ = *src++) != '\0') {
|
||||
dest_buf_size--;
|
||||
if (__predict_false(dest_buf_size == 0)) {
|
||||
__fortify_chk_fail("strcat: prevented write past end of buffer",
|
||||
BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW);
|
||||
}
|
||||
}
|
||||
|
||||
return save;
|
||||
return save;
|
||||
}
|
||||
|
|
|
@ -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("strchr prevented read past end of buffer", 0);
|
||||
__fortify_chk_fail("strchr: prevented read past end of buffer", 0);
|
||||
}
|
||||
if (*p == static_cast<char>(ch)) {
|
||||
return const_cast<char*>(p);
|
||||
|
|
|
@ -41,13 +41,13 @@
|
|||
* This strcpy check is called if _FORTIFY_SOURCE is defined and
|
||||
* greater than 0.
|
||||
*/
|
||||
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 prevented write past end of buffer",
|
||||
BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW);
|
||||
}
|
||||
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: prevented write past end of buffer",
|
||||
BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
return strcpy(dest, src);
|
||||
return strcpy(dest, src);
|
||||
}
|
||||
|
|
|
@ -42,12 +42,11 @@
|
|||
* This strlcat check is called if _FORTIFY_SOURCE is defined and
|
||||
* greater than 0.
|
||||
*/
|
||||
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 prevented write past end of buffer", 0);
|
||||
}
|
||||
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: prevented write past end of buffer", 0);
|
||||
}
|
||||
|
||||
return strlcat(dest, src, supplied_size);
|
||||
return strlcat(dest, src, supplied_size);
|
||||
}
|
||||
|
|
|
@ -42,12 +42,11 @@
|
|||
* This strlcpy check is called if _FORTIFY_SOURCE is defined and
|
||||
* greater than 0.
|
||||
*/
|
||||
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 prevented write past end of buffer", 0);
|
||||
}
|
||||
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: prevented write past end of buffer", 0);
|
||||
}
|
||||
|
||||
return strlcpy(dest, src, supplied_size);
|
||||
return strlcpy(dest, src, supplied_size);
|
||||
}
|
||||
|
|
|
@ -53,12 +53,12 @@
|
|||
*
|
||||
* or anytime strlen reads beyond an object boundary.
|
||||
*/
|
||||
extern "C" size_t __strlen_chk(const char *s, size_t s_len) {
|
||||
size_t ret = strlen(s);
|
||||
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 prevented read past end of buffer", 0);
|
||||
}
|
||||
if (__predict_false(ret >= s_len)) {
|
||||
__fortify_chk_fail("strlen: prevented read past end of buffer", 0);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -41,33 +41,30 @@
|
|||
* This strncat check is called if _FORTIFY_SOURCE is defined and
|
||||
* greater than 0.
|
||||
*/
|
||||
extern "C" char *__strncat_chk(
|
||||
char* __restrict dest,
|
||||
const char* __restrict src,
|
||||
size_t len, size_t dest_buf_size)
|
||||
{
|
||||
if (len == 0) {
|
||||
return dest;
|
||||
}
|
||||
|
||||
size_t dest_len = __strlen_chk(dest, dest_buf_size);
|
||||
char *d = dest + dest_len;
|
||||
dest_buf_size -= dest_len;
|
||||
|
||||
while (*src != '\0') {
|
||||
*d++ = *src++;
|
||||
len--; dest_buf_size--;
|
||||
|
||||
if (__predict_false(dest_buf_size == 0)) {
|
||||
__fortify_chk_fail("strncat prevented write past end of buffer",
|
||||
BIONIC_EVENT_STRNCAT_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*d = '\0';
|
||||
extern "C" char* __strncat_chk(char* __restrict dest, const char* __restrict src,
|
||||
size_t len, size_t dest_buf_size) {
|
||||
if (len == 0) {
|
||||
return dest;
|
||||
}
|
||||
|
||||
size_t dest_len = __strlen_chk(dest, dest_buf_size);
|
||||
char *d = dest + dest_len;
|
||||
dest_buf_size -= dest_len;
|
||||
|
||||
while (*src != '\0') {
|
||||
*d++ = *src++;
|
||||
len--; dest_buf_size--;
|
||||
|
||||
if (__predict_false(dest_buf_size == 0)) {
|
||||
__fortify_chk_fail("strncat: prevented write past end of buffer",
|
||||
BIONIC_EVENT_STRNCAT_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*d = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
|
|
@ -42,10 +42,9 @@
|
|||
* greater than 0.
|
||||
*/
|
||||
extern "C" char* __strncpy_chk(char* __restrict dest, const char* __restrict src,
|
||||
size_t len, size_t dest_len)
|
||||
{
|
||||
size_t len, size_t dest_len) {
|
||||
if (__predict_false(len > dest_len)) {
|
||||
__fortify_chk_fail("strncpy prevented write past end of buffer",
|
||||
__fortify_chk_fail("strncpy: prevented write past end of buffer",
|
||||
BIONIC_EVENT_STRNCPY_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
|
@ -64,7 +63,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 prevented write past end of buffer",
|
||||
__fortify_chk_fail("strncpy: prevented write past end of buffer",
|
||||
BIONIC_EVENT_STRNCPY_BUFFER_OVERFLOW);
|
||||
}
|
||||
if (n != 0) {
|
||||
|
@ -83,7 +82,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 prevented read past end of buffer", 0);
|
||||
__fortify_chk_fail("strncpy: prevented read past end of buffer", 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,17 +31,17 @@
|
|||
#include <string.h>
|
||||
#include "private/libc_logging.h"
|
||||
|
||||
extern "C" char* __strrchr_chk(const char *p, int ch, size_t s_len)
|
||||
{
|
||||
char *save;
|
||||
|
||||
for (save = NULL;; ++p, s_len--) {
|
||||
if (s_len == 0)
|
||||
__fortify_chk_fail("strrchr prevented read past end of buffer", 0);
|
||||
if (*p == (char) ch)
|
||||
save = (char *)p;
|
||||
if (!*p)
|
||||
return(save);
|
||||
extern "C" char* __strrchr_chk(const char *p, int ch, size_t s_len) {
|
||||
for (char* save = NULL;; ++p, s_len--) {
|
||||
if (s_len == 0) {
|
||||
__fortify_chk_fail("strrchr: prevented read past end of buffer", 0);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
if (*p == (char) ch) {
|
||||
save = (char *)p;
|
||||
}
|
||||
if (!*p) {
|
||||
return(save);
|
||||
}
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
|
|
@ -43,9 +43,9 @@
|
|||
* greater than 0.
|
||||
*/
|
||||
extern "C" mode_t __umask_chk(mode_t mode) {
|
||||
if (__predict_false((mode & 0777) != mode)) {
|
||||
__fortify_chk_fail("umask called with invalid mask", 0);
|
||||
}
|
||||
if (__predict_false((mode & 0777) != mode)) {
|
||||
__fortify_chk_fail("umask: called with invalid mask", 0);
|
||||
}
|
||||
|
||||
return umask(mode);
|
||||
return umask(mode);
|
||||
}
|
||||
|
|
|
@ -42,19 +42,13 @@
|
|||
* This vsnprintf check is called if _FORTIFY_SOURCE is defined and
|
||||
* greater than 0.
|
||||
*/
|
||||
extern "C" int __vsnprintf_chk(
|
||||
char *dest,
|
||||
size_t supplied_size,
|
||||
int /*flags*/,
|
||||
size_t dest_len_from_compiler,
|
||||
const char *format,
|
||||
va_list va)
|
||||
{
|
||||
if (__predict_false(supplied_size > dest_len_from_compiler)) {
|
||||
__fortify_chk_fail("vsnprintf prevented write past end of buffer", 0);
|
||||
}
|
||||
extern "C" int __vsnprintf_chk(char* dest, size_t supplied_size, int /*flags*/,
|
||||
size_t dest_len_from_compiler, const char* format, va_list va) {
|
||||
if (__predict_false(supplied_size > dest_len_from_compiler)) {
|
||||
__fortify_chk_fail("vsnprintf: prevented write past end of buffer", 0);
|
||||
}
|
||||
|
||||
return vsnprintf(dest, supplied_size, format, va);
|
||||
return vsnprintf(dest, supplied_size, format, va);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -68,20 +62,11 @@ extern "C" int __vsnprintf_chk(
|
|||
* 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;
|
||||
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;
|
||||
va_start(va, format);
|
||||
int result = __vsnprintf_chk(dest, supplied_size, flags, dest_len_from_compiler, format, va);
|
||||
va_end(va);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -42,20 +42,13 @@
|
|||
* This vsprintf check is called if _FORTIFY_SOURCE is defined and
|
||||
* greater than 0.
|
||||
*/
|
||||
extern "C" int __vsprintf_chk(
|
||||
char *dest,
|
||||
int /*flags*/,
|
||||
size_t dest_len_from_compiler,
|
||||
const char *format,
|
||||
va_list va)
|
||||
{
|
||||
int ret = vsnprintf(dest, dest_len_from_compiler, format, va);
|
||||
|
||||
if ((size_t) ret >= dest_len_from_compiler) {
|
||||
__fortify_chk_fail("vsprintf prevented write past end of buffer", 0);
|
||||
}
|
||||
|
||||
return ret;
|
||||
extern "C" int __vsprintf_chk(char* dest, int /*flags*/,
|
||||
size_t dest_len_from_compiler, const char* format, va_list va) {
|
||||
int result = vsnprintf(dest, dest_len_from_compiler, format, va);
|
||||
if ((size_t) result >= dest_len_from_compiler) {
|
||||
__fortify_chk_fail("vsprintf: prevented write past end of buffer", 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -69,19 +62,11 @@ extern "C" int __vsprintf_chk(
|
|||
* 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;
|
||||
extern "C" int __sprintf_chk(char* dest, int flags,
|
||||
size_t dest_len_from_compiler, const char* format, ...) {
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
int result = __vsprintf_chk(dest, flags, dest_len_from_compiler, format, va);
|
||||
va_end(va);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -504,7 +504,7 @@ void __libc_android_log_event_uid(int32_t tag) {
|
|||
__libc_android_log_event_int(tag, getuid());
|
||||
}
|
||||
|
||||
void __fortify_chk_fail(const char *msg, uint32_t tag) {
|
||||
void __fortify_chk_fail(const char* msg, uint32_t tag) {
|
||||
if (tag != 0) {
|
||||
__libc_android_log_event_uid(tag);
|
||||
}
|
||||
|
|
|
@ -33,30 +33,27 @@
|
|||
|
||||
extern int __open(const char*, int, int);
|
||||
|
||||
int open(const char *pathname, int flags, ...)
|
||||
{
|
||||
mode_t mode = 0;
|
||||
int open(const char* pathname, int flags, ...) {
|
||||
mode_t mode = 0;
|
||||
|
||||
flags |= O_LARGEFILE;
|
||||
flags |= O_LARGEFILE;
|
||||
|
||||
if (flags & O_CREAT)
|
||||
{
|
||||
va_list args;
|
||||
if (flags & O_CREAT) {
|
||||
va_list args;
|
||||
va_start(args, flags);
|
||||
mode = (mode_t) va_arg(args, int);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
va_start(args, flags);
|
||||
mode = (mode_t) va_arg(args, int);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
return __open(pathname, flags, mode);
|
||||
return __open(pathname, flags, mode);
|
||||
}
|
||||
|
||||
int __open_2(const char *pathname, int flags) {
|
||||
if (__predict_false(flags & O_CREAT)) {
|
||||
__fortify_chk_fail("open(O_CREAT) called without specifying a mode", 0);
|
||||
}
|
||||
int __open_2(const char* pathname, int flags) {
|
||||
if (__predict_false(flags & O_CREAT)) {
|
||||
__fortify_chk_fail("open(O_CREAT): called without specifying a mode", 0);
|
||||
}
|
||||
|
||||
flags |= O_LARGEFILE;
|
||||
flags |= O_LARGEFILE;
|
||||
|
||||
return __open(pathname, flags, 0);
|
||||
return __open(pathname, flags, 0);
|
||||
}
|
||||
|
|
|
@ -33,31 +33,27 @@
|
|||
|
||||
extern int __openat(int, const char*, int, int);
|
||||
|
||||
int openat(int fd, const char *pathname, int flags, ...)
|
||||
{
|
||||
mode_t mode = 0;
|
||||
int openat(int fd, const char *pathname, int flags, ...) {
|
||||
mode_t mode = 0;
|
||||
|
||||
flags |= O_LARGEFILE;
|
||||
flags |= O_LARGEFILE;
|
||||
|
||||
if (flags & O_CREAT)
|
||||
{
|
||||
va_list args;
|
||||
if (flags & O_CREAT) {
|
||||
va_list args;
|
||||
va_start(args, flags);
|
||||
mode = (mode_t) va_arg(args, int);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
va_start(args, flags);
|
||||
mode = (mode_t) va_arg(args, int);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
return __openat(fd, pathname, flags, mode);
|
||||
return __openat(fd, pathname, flags, mode);
|
||||
}
|
||||
|
||||
int __openat_2(int fd, const char *pathname, int flags)
|
||||
{
|
||||
if (flags & O_CREAT) {
|
||||
__fortify_chk_fail("openat(O_CREAT) called without specifying a mode", 0);
|
||||
}
|
||||
int __openat_2(int fd, const char* pathname, int flags) {
|
||||
if (flags & O_CREAT) {
|
||||
__fortify_chk_fail("openat(O_CREAT): called without specifying a mode", 0);
|
||||
}
|
||||
|
||||
flags |= O_LARGEFILE;
|
||||
flags |= O_LARGEFILE;
|
||||
|
||||
return __openat(fd, pathname, flags, 0);
|
||||
return __openat(fd, pathname, flags, 0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue