forked from OSchip/llvm-project
[ASan] one more macro for 'read' interception
llvm-svn: 170114
This commit is contained in:
parent
3e7ede230f
commit
447e2f2f19
|
@ -154,7 +154,9 @@ DECLARE_FUNCTION_AND_WRAPPER(long long, strtoll, const char *nptr, char **endptr
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
// unistd.h
|
// unistd.h
|
||||||
|
# if SANITIZER_INTERCEPT_READ
|
||||||
DECLARE_FUNCTION_AND_WRAPPER(SSIZE_T, read, int fd, void *buf, SIZE_T count);
|
DECLARE_FUNCTION_AND_WRAPPER(SSIZE_T, read, int fd, void *buf, SIZE_T count);
|
||||||
|
# endif
|
||||||
# if SANITIZER_INTERCEPT_PREAD
|
# if SANITIZER_INTERCEPT_PREAD
|
||||||
DECLARE_FUNCTION_AND_WRAPPER(SSIZE_T, pread, int fd, void *buf,
|
DECLARE_FUNCTION_AND_WRAPPER(SSIZE_T, pread, int fd, void *buf,
|
||||||
SIZE_T count, OFF_T offset);
|
SIZE_T count, OFF_T offset);
|
||||||
|
|
|
@ -23,8 +23,10 @@
|
||||||
#include "interception/interception.h"
|
#include "interception/interception.h"
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
|
# define SANITIZER_INTERCEPT_READ 1
|
||||||
# define SANITIZER_INTERCEPT_PREAD 1
|
# define SANITIZER_INTERCEPT_PREAD 1
|
||||||
#else
|
#else
|
||||||
|
# define SANITIZER_INTERCEPT_READ 0
|
||||||
# define SANITIZER_INTERCEPT_PREAD 0
|
# define SANITIZER_INTERCEPT_PREAD 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -34,6 +36,7 @@
|
||||||
# define SANITIZER_INTERCEPT_PREAD64 0
|
# define SANITIZER_INTERCEPT_PREAD64 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if SANITIZER_INTERCEPT_READ
|
||||||
INTERCEPTOR(SSIZE_T, read, int fd, void *ptr, SIZE_T count) {
|
INTERCEPTOR(SSIZE_T, read, int fd, void *ptr, SIZE_T count) {
|
||||||
COMMON_INTERCEPTOR_ENTER(read, fd, ptr, count);
|
COMMON_INTERCEPTOR_ENTER(read, fd, ptr, count);
|
||||||
SSIZE_T res = REAL(read)(fd, ptr, count);
|
SSIZE_T res = REAL(read)(fd, ptr, count);
|
||||||
|
@ -41,6 +44,7 @@ INTERCEPTOR(SSIZE_T, read, int fd, void *ptr, SIZE_T count) {
|
||||||
COMMON_INTERCEPTOR_WRITE_RANGE(ptr, res);
|
COMMON_INTERCEPTOR_WRITE_RANGE(ptr, res);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if SANITIZER_INTERCEPT_PREAD
|
#if SANITIZER_INTERCEPT_PREAD
|
||||||
INTERCEPTOR(SSIZE_T, pread, int fd, void *ptr, SIZE_T count, OFF_T offset) {
|
INTERCEPTOR(SSIZE_T, pread, int fd, void *ptr, SIZE_T count, OFF_T offset) {
|
||||||
|
@ -62,6 +66,12 @@ INTERCEPTOR(SSIZE_T, pread64, int fd, void *ptr, SIZE_T count, OFF64_T offset) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if SANITIZER_INTERCEPT_READ
|
||||||
|
# define INIT_READ CHECK(INTERCEPT_FUNCTION(read))
|
||||||
|
#else
|
||||||
|
# define INIT_READ
|
||||||
|
#endif
|
||||||
|
|
||||||
#if SANITIZER_INTERCEPT_PREAD
|
#if SANITIZER_INTERCEPT_PREAD
|
||||||
# define INIT_PREAD CHECK(INTERCEPT_FUNCTION(pread))
|
# define INIT_PREAD CHECK(INTERCEPT_FUNCTION(pread))
|
||||||
#else
|
#else
|
||||||
|
@ -75,7 +85,7 @@ INTERCEPTOR(SSIZE_T, pread64, int fd, void *ptr, SIZE_T count, OFF64_T offset) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SANITIZER_COMMON_INTERCEPTORS_INIT \
|
#define SANITIZER_COMMON_INTERCEPTORS_INIT \
|
||||||
CHECK(INTERCEPT_FUNCTION(read)); \
|
INIT_READ; \
|
||||||
INIT_PREAD; \
|
INIT_PREAD; \
|
||||||
INIT_PREAD64; \
|
INIT_PREAD64; \
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue