summaryrefslogtreecommitdiff
path: root/test/msan/Linux/bzero.cc
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2019-03-04 22:58:11 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2019-03-04 22:58:11 +0000
commit319d511ba4db9c8a60c55fb6991abc53c9708d8a (patch)
tree9b67e7eb75fff34363e6a41a3ddfc05f6b2741fc /test/msan/Linux/bzero.cc
parentda91a27b9d940dde91a8a3090d2f26ed17d8295e (diff)
downloadcompiler-rt-319d511ba4db9c8a60c55fb6991abc53c9708d8a.tar.gz
[sanitizer] Intercept bzero.
Summary: Intercept bzero and enable existing __bzero interceptor in Linux. bzero is deprecated but still used occasionally. Reviewers: vitalybuka Subscribers: srhines, kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58850 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355347 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/msan/Linux/bzero.cc')
-rw-r--r--test/msan/Linux/bzero.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/msan/Linux/bzero.cc b/test/msan/Linux/bzero.cc
new file mode 100644
index 000000000..cb319a6cf
--- /dev/null
+++ b/test/msan/Linux/bzero.cc
@@ -0,0 +1,16 @@
+// RUN: %clangxx_msan -O0 %s -o %t && %run %t
+
+// REQUIRES: !android
+
+#include <assert.h>
+#include <strings.h>
+#include <sanitizer/msan_interface.h>
+
+int main(int argc, char *argv[]) {
+ char buf[100];
+ assert(0 == __msan_test_shadow(buf, sizeof(buf)));
+ // *& to suppress bzero-to-memset optimization.
+ (*&bzero)(buf, 50);
+ assert(50 == __msan_test_shadow(buf, sizeof(buf)));
+ return 0;
+}