forked from OSchip/llvm-project
[Sanitizer] Intercepts flopen/flopenat on FreeBSD.
Reviewers: vitalybuka Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D106218
This commit is contained in:
parent
9333d34b8a
commit
2d56e1394b
|
@ -6104,6 +6104,40 @@ INTERCEPTOR(__sanitizer_FILE *, freopen, const char *path, const char *mode,
|
|||
#define INIT_FOPEN
|
||||
#endif
|
||||
|
||||
#if SANITIZER_INTERCEPT_FLOPEN
|
||||
INTERCEPTOR(int, flopen, const char *path, int flags, ...) {
|
||||
void *ctx;
|
||||
va_list ap;
|
||||
va_start(ap, flags);
|
||||
u16 mode = static_cast<u16>(va_arg(ap, u32));
|
||||
va_end(ap);
|
||||
COMMON_INTERCEPTOR_ENTER(ctx, flopen, path, flags, mode);
|
||||
if (path) {
|
||||
COMMON_INTERCEPTOR_READ_RANGE(ctx, path, REAL(strlen)(path) + 1);
|
||||
}
|
||||
return REAL(flopen)(path, flags, mode);
|
||||
}
|
||||
|
||||
INTERCEPTOR(int, flopenat, int dirfd, const char *path, int flags, ...) {
|
||||
void *ctx;
|
||||
va_list ap;
|
||||
va_start(ap, flags);
|
||||
u16 mode = static_cast<u16>(va_arg(ap, u32));
|
||||
va_end(ap);
|
||||
COMMON_INTERCEPTOR_ENTER(ctx, flopen, path, flags, mode);
|
||||
if (path) {
|
||||
COMMON_INTERCEPTOR_READ_RANGE(ctx, path, REAL(strlen)(path) + 1);
|
||||
}
|
||||
return REAL(flopenat)(dirfd, path, flags, mode);
|
||||
}
|
||||
|
||||
#define INIT_FLOPEN \
|
||||
COMMON_INTERCEPT_FUNCTION(flopen); \
|
||||
COMMON_INTERCEPT_FUNCTION(flopenat);
|
||||
#else
|
||||
#define INIT_FLOPEN
|
||||
#endif
|
||||
|
||||
#if SANITIZER_INTERCEPT_FOPEN64
|
||||
INTERCEPTOR(__sanitizer_FILE *, fopen64, const char *path, const char *mode) {
|
||||
void *ctx;
|
||||
|
@ -10269,6 +10303,7 @@ static void InitializeCommonInterceptors() {
|
|||
INIT_LIBIO_INTERNALS;
|
||||
INIT_FOPEN;
|
||||
INIT_FOPEN64;
|
||||
INIT_FLOPEN;
|
||||
INIT_OPEN_MEMSTREAM;
|
||||
INIT_OBSTACK;
|
||||
INIT_FFLUSH;
|
||||
|
|
|
@ -577,6 +577,7 @@
|
|||
(SI_POSIX && !(SANITIZER_MAC && SANITIZER_I386))
|
||||
#define SANITIZER_INTERCEPT_UNAME (SI_POSIX && !SI_FREEBSD)
|
||||
#define SANITIZER_INTERCEPT___XUNAME SI_FREEBSD
|
||||
#define SANITIZER_INTERCEPT_FLOPEN SI_FREEBSD
|
||||
|
||||
// This macro gives a way for downstream users to override the above
|
||||
// interceptor macros irrespective of the platform they are on. They have
|
||||
|
|
Loading…
Reference in New Issue