forked from OSchip/llvm-project
parent
c7c0445443
commit
04621bd888
|
@ -5285,6 +5285,36 @@ INTERCEPTOR(SSIZE_T, process_vm_writev, int pid, __sanitizer_iovec *local_iov,
|
|||
#define INIT_PROCESS_VM_READV
|
||||
#endif
|
||||
|
||||
#if SANITIZER_INTERCEPT_CTERMID
|
||||
INTERCEPTOR(char *, ctermid, char *s) {
|
||||
void *ctx;
|
||||
COMMON_INTERCEPTOR_ENTER(ctx, ctermid, s);
|
||||
char *res = REAL(ctermid)(s);
|
||||
if (res) {
|
||||
COMMON_INTERCEPTOR_INITIALIZE_RANGE(res, REAL(strlen)(res) + 1);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
#define INIT_CTERMID COMMON_INTERCEPT_FUNCTION(ctermid);
|
||||
#else
|
||||
#define INIT_CTERMID
|
||||
#endif
|
||||
|
||||
#if SANITIZER_INTERCEPT_CTERMID_R
|
||||
INTERCEPTOR(char *, ctermid_r, char *s) {
|
||||
void *ctx;
|
||||
COMMON_INTERCEPTOR_ENTER(ctx, ctermid_r, s);
|
||||
char *res = REAL(ctermid_r)(s);
|
||||
if (res) {
|
||||
COMMON_INTERCEPTOR_INITIALIZE_RANGE(res, REAL(strlen)(res) + 1);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
#define INIT_CTERMID_R COMMON_INTERCEPT_FUNCTION(ctermid_r);
|
||||
#else
|
||||
#define INIT_CTERMID_R
|
||||
#endif
|
||||
|
||||
static void InitializeCommonInterceptors() {
|
||||
static u64 metadata_mem[sizeof(MetadataHashMap) / sizeof(u64) + 1];
|
||||
interceptor_metadata_map = new((void *)&metadata_mem) MetadataHashMap();
|
||||
|
@ -5459,4 +5489,6 @@ static void InitializeCommonInterceptors() {
|
|||
INIT_PTHREAD_SETCANCEL;
|
||||
INIT_MINCORE;
|
||||
INIT_PROCESS_VM_READV;
|
||||
INIT_CTERMID;
|
||||
INIT_CTERMID_R;
|
||||
}
|
||||
|
|
|
@ -260,6 +260,8 @@
|
|||
#define SANITIZER_INTERCEPT_PTHREAD_SETCANCEL SI_NOT_WINDOWS
|
||||
#define SANITIZER_INTERCEPT_MINCORE SI_LINUX
|
||||
#define SANITIZER_INTERCEPT_PROCESS_VM_READV SI_LINUX
|
||||
#define SANITIZER_INTERCEPT_CTERMID SI_LINUX || SI_MAC || SI_FREEBSD
|
||||
#define SANITIZER_INTERCEPT_CTERMID_R SI_MAC || SI_FREEBSD
|
||||
|
||||
#define SANITIZER_INTERCEPTOR_HOOKS SI_LINUX
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
// RUN: %clangxx_msan -std=c++11 -O0 %s -o %t && %run %t
|
||||
|
||||
#include <sanitizer/msan_interface.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void) {
|
||||
unsigned char s[L_ctermid + 1];
|
||||
char *res = ctermid((char *)s);
|
||||
if (res)
|
||||
printf("%zd\n", strlen(res));
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue