summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2014-03-28 11:21:45 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2014-03-28 11:21:45 +0000
commit8e032e5d21f3116a6adbcaa7a828903b02392ad6 (patch)
tree1132236150cdd4df6d63d5840199daad9fadec8b /lib
parent518dbfde26c2eb8435e385b6b688c7019d92d64f (diff)
[sanitizer] Intercept rand_r.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@205001 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/sanitizer_common/sanitizer_common_interceptors.inc13
-rw-r--r--lib/sanitizer_common/sanitizer_platform_interceptors.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_common_interceptors.inc b/lib/sanitizer_common/sanitizer_common_interceptors.inc
index dd60db295..215740935 100644
--- a/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -3232,6 +3232,18 @@ INTERCEPTOR(int, lrand48_r, void *buffer, long *result) {
#define INIT_DRAND48_R
#endif
+#if SANITIZER_INTERCEPT_RAND_R
+INTERCEPTOR(int, rand_r, unsigned *seedp) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, rand_r, seedp);
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, seedp, sizeof(*seedp));
+ return REAL(rand_r)(seedp);
+}
+#define INIT_RAND_R COMMON_INTERCEPT_FUNCTION(rand_r);
+#else
+#define INIT_RAND_R
+#endif
+
#if SANITIZER_INTERCEPT_GETLINE
INTERCEPTOR(SSIZE_T, getline, char **lineptr, SIZE_T *n, void *stream) {
void *ctx;
@@ -3704,6 +3716,7 @@ INTERCEPTOR(int, ftime, __sanitizer_timeb *tp) {
INIT_LGAMMA; \
INIT_LGAMMA_R; \
INIT_DRAND48_R; \
+ INIT_RAND_R; \
INIT_GETLINE; \
INIT_ICONV; \
INIT_TIMES; \
diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h
index 055a13f31..dc559398c 100644
--- a/lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -169,6 +169,7 @@
#define SANITIZER_INTERCEPT_LGAMMA SI_NOT_WINDOWS
#define SANITIZER_INTERCEPT_LGAMMA_R SI_LINUX
#define SANITIZER_INTERCEPT_DRAND48_R SI_LINUX_NOT_ANDROID
+#define SANITIZER_INTERCEPT_RAND_R SI_MAC || SI_LINUX_NOT_ANDROID
#define SANITIZER_INTERCEPT_ICONV SI_LINUX_NOT_ANDROID
#define SANITIZER_INTERCEPT_TIMES SI_NOT_WINDOWS