forked from OSchip/llvm-project
[sanitizer] Add interceptor for ttyname_r
Reviewers: eugenis Subscribers: kubabrecka, llvm-commits Differential Revision: https://reviews.llvm.org/D24375 llvm-svn: 281116
This commit is contained in:
parent
efcc5c4390
commit
8dc0e0943b
|
@ -4183,6 +4183,20 @@ INTERCEPTOR(char *, tmpnam_r, char *s) {
|
|||
#define INIT_TMPNAM_R
|
||||
#endif
|
||||
|
||||
#if SANITIZER_INTERCEPT_TTYNAME_R
|
||||
INTERCEPTOR(int, ttyname_r, int fd, char *name, SIZE_T namesize) {
|
||||
void *ctx;
|
||||
COMMON_INTERCEPTOR_ENTER(ctx, ttyname_r, fd, name, namesize);
|
||||
int res = REAL(ttyname_r)(fd, name, namesize);
|
||||
if (res == 0)
|
||||
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, name, REAL(strlen)(name) + 1);
|
||||
return res;
|
||||
}
|
||||
#define INIT_TTYNAME_R COMMON_INTERCEPT_FUNCTION(ttyname_r);
|
||||
#else
|
||||
#define INIT_TTYNAME_R
|
||||
#endif
|
||||
|
||||
#if SANITIZER_INTERCEPT_TEMPNAM
|
||||
INTERCEPTOR(char *, tempnam, char *dir, char *pfx) {
|
||||
void *ctx;
|
||||
|
@ -6008,6 +6022,7 @@ static void InitializeCommonInterceptors() {
|
|||
INIT_PTHREAD_BARRIERATTR_GETPSHARED;
|
||||
INIT_TMPNAM;
|
||||
INIT_TMPNAM_R;
|
||||
INIT_TTYNAME_R;
|
||||
INIT_TEMPNAM;
|
||||
INIT_PTHREAD_SETNAME_NP;
|
||||
INIT_SINCOS;
|
||||
|
|
|
@ -235,6 +235,7 @@
|
|||
#define SANITIZER_INTERCEPT_PTHREAD_BARRIERATTR_GETPSHARED SI_LINUX_NOT_ANDROID
|
||||
#define SANITIZER_INTERCEPT_TMPNAM SI_NOT_WINDOWS
|
||||
#define SANITIZER_INTERCEPT_TMPNAM_R SI_LINUX_NOT_ANDROID
|
||||
#define SANITIZER_INTERCEPT_TTYNAME_R SI_NOT_WINDOWS
|
||||
#define SANITIZER_INTERCEPT_TEMPNAM SI_NOT_WINDOWS
|
||||
#define SANITIZER_INTERCEPT_SINCOS SI_LINUX
|
||||
#define SANITIZER_INTERCEPT_REMQUO SI_NOT_WINDOWS
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <pty.h>
|
||||
#include <unistd.h>
|
||||
#include <cstring>
|
||||
|
||||
#include <sanitizer/msan_interface.h>
|
||||
|
||||
|
@ -13,6 +15,10 @@ main (int argc, char** argv)
|
|||
assert(__msan_test_shadow(&master, sizeof(master)) == -1);
|
||||
assert(__msan_test_shadow(&slave, sizeof(slave)) == -1);
|
||||
|
||||
char ttyname[255];
|
||||
ttyname_r(master, ttyname, sizeof(ttyname));
|
||||
assert(__msan_test_shadow(ttyname, strlen(ttyname) + 1) == -1);
|
||||
|
||||
int master2;
|
||||
forkpty(&master2, NULL, NULL, NULL);
|
||||
assert(__msan_test_shadow(&master2, sizeof(master2)) == -1);
|
||||
|
|
Loading…
Reference in New Issue