[PATCH] D24375: [sanitizer] Add interceptor for ttyname_r
Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 9 16:18:11 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281116: [sanitizer] Add interceptor for ttyname_r (authored by kfischer).
Changed prior to commit:
https://reviews.llvm.org/D24375?vs=70920&id=70925#toc
Repository:
rL LLVM
https://reviews.llvm.org/D24375
Files:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
compiler-rt/trunk/test/msan/Linux/forkpty.cc
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -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
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -4183,6 +4183,20 @@
#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 @@
INIT_PTHREAD_BARRIERATTR_GETPSHARED;
INIT_TMPNAM;
INIT_TMPNAM_R;
+ INIT_TTYNAME_R;
INIT_TEMPNAM;
INIT_PTHREAD_SETNAME_NP;
INIT_SINCOS;
Index: compiler-rt/trunk/test/msan/Linux/forkpty.cc
===================================================================
--- compiler-rt/trunk/test/msan/Linux/forkpty.cc
+++ compiler-rt/trunk/test/msan/Linux/forkpty.cc
@@ -2,6 +2,8 @@
#include <assert.h>
#include <pty.h>
+#include <unistd.h>
+#include <cstring>
#include <sanitizer/msan_interface.h>
@@ -13,6 +15,10 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24375.70925.patch
Type: text/x-patch
Size: 2553 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160909/95c15cb6/attachment.bin>
More information about the llvm-commits
mailing list