pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

compiler-rt-netbsd: Rebase to Yang Zheng's GSoC branch with patches



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Thu Jun 7 12:13:19 2018 +0200
Changeset:	0c20781295bac208619cacb700ec3279de974036

Modified Files:
	compiler-rt-netbsd/distinfo
	compiler-rt-netbsd/patches/patch-lib_fuzzer_FuzzerLoop.cpp
	compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.cc
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h
Added Files:
	compiler-rt-netbsd/patches/patch-lib_esan_esan__interceptors.cpp
	compiler-rt-netbsd/patches/patch-lib_interception_interception.h
	compiler-rt-netbsd/patches/patch-lib_tsan_CMakeLists.txt
	compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc
	compiler-rt-netbsd/patches/patch-test_fuzzer_NullDerefTest.cpp
Removed Files:
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc

Log Message:
compiler-rt-netbsd: Rebase to Yang Zheng's GSoC branch with patches

A lot of new interceptors and fixes in preparation for MKSANITIZER.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=0c20781295bac208619cacb700ec3279de974036

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 compiler-rt-netbsd/distinfo                        |  20 +-
 .../patches/patch-lib_esan_esan__interceptors.cpp  |  26 +
 .../patches/patch-lib_fuzzer_FuzzerLoop.cpp        |   4 +-
 .../patches/patch-lib_interception_interception.h  |  12 +
 .../patches/patch-lib_msan_msan__interceptors.cc   |   2 +-
 ...zer__common_sanitizer__common__interceptors.inc | 823 ++++++++++++++++++++-
 ...patch-lib_sanitizer__common_sanitizer__linux.cc |   2 +-
 ..._sanitizer__common_sanitizer__linux__libcdep.cc |  12 -
 ...zer__common_sanitizer__platform__interceptors.h |  16 +-
 ...__common_sanitizer__platform__limits__netbsd.cc |  55 +-
 ...r__common_sanitizer__platform__limits__netbsd.h |  29 +
 .../patches/patch-lib_tsan_CMakeLists.txt          |  13 +
 .../patch-lib_tsan_rtl_tsan__interceptors.cc       |  25 +
 .../patches/patch-test_fuzzer_NullDerefTest.cpp    |   9 +
 14 files changed, 1018 insertions(+), 30 deletions(-)

diffs:
diff --git a/compiler-rt-netbsd/distinfo b/compiler-rt-netbsd/distinfo
index 85668eaec8..552f4b5097 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -3,23 +3,27 @@ $NetBSD: distinfo,v 1.35 2015/09/11 01:21:57 tnn Exp $
 SHA1 (patch-CMakeLists.txt) = b80970b86107f4e17f994433e743f83160f71428
 SHA1 (patch-cmake_config-ix.cmake) = c2ac835eb5cddaf2d4820b0d21e36e18d29bd1a5
 SHA1 (patch-lib_asan_asan__posix.cc) = 0f596061c078eaab0b5b4b183550aa7820677f46
-SHA1 (patch-lib_fuzzer_FuzzerLoop.cpp) = 9e86608f740e199b0c1f9b6285f8e5ac3412486a
+SHA1 (patch-lib_esan_esan__interceptors.cpp) = d65c31b0d44330c669bf6d81a3cfa51954078c32
+SHA1 (patch-lib_fuzzer_FuzzerLoop.cpp) = 01456bfacb94c06e008eefc660781d3c7bb1c2e7
 SHA1 (patch-lib_fuzzer_tests_CMakeLists.txt) = e2e0e397eaf148df329f2c25ca9185f57989d082
-SHA1 (patch-lib_msan_msan__interceptors.cc) = ae0e856572160c24697d61767c28453f12d092e5
+SHA1 (patch-lib_interception_interception.h) = a7f97b191769c846be27e17430bbe39435976642
+SHA1 (patch-lib_msan_msan__interceptors.cc) = b8d6a174a0b302a87d3f1489a439f186b034313d
 SHA1 (patch-lib_msan_msan__linux.cc) = 6fd2ada4a84d1e1cc47ec8f4e1f0608861c73c1a
-SHA1 (patch-lib_sanitizer__common_sanitizer__common__interceptors.inc) = e1d8ad46afc9bec97b7f0e00d0edf5ee377772b7
+SHA1 (patch-lib_sanitizer__common_sanitizer__common__interceptors.inc) = 29c7d1fe89a358098d5a68f83a2940f46c77ccc6
 SHA1 (patch-lib_sanitizer__common_sanitizer__internal__defs.h) = 9ffcb3ae5ccfcb99d842efe55f6d698cd2e02846
-SHA1 (patch-lib_sanitizer__common_sanitizer__linux.cc) = da916c2d72f726c3bd1438568d3e90cb952148b0
-SHA1 (patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc) = c1ce6657580cc0865808dd713d1f28afc3baaaa7
-SHA1 (patch-lib_sanitizer__common_sanitizer__platform__interceptors.h) = dbe5aee67312a9042299cd3bd14d25fa68860fb2
-SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.cc) = f242e307950755010305b004b4c2e21c528114fb
-SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h) = a5f5898534bd3c66a0fa9086781bd0124fe43281
+SHA1 (patch-lib_sanitizer__common_sanitizer__linux.cc) = 83636321cef6a17281a27e2ed3dd1b71e5429a6a
+SHA1 (patch-lib_sanitizer__common_sanitizer__platform__interceptors.h) = 085ebe6709bf834a6c663c845e0f0e118f759b05
+SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.cc) = c77fa6e013e776a48ed43b1c244b4430e7590c50
+SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h) = c47538580572ffdae14b095df76739a603a63a32
 SHA1 (patch-lib_sanitizer__common_sanitizer__procmaps__bsd.cc) = 8b629840ff7f56c670d322a9dbbdf7e33ce90cb5
 SHA1 (patch-lib_sanitizer__common_sanitizer__unwind__linux__libcdep.cc) = 5225619de386fa8e017b6d391c9f1eba4bdda2af
 SHA1 (patch-lib_scudo_scudo__platform.h) = 119d7ad8f8ca9d3e846dbdd7f805ca771e30e410
+SHA1 (patch-lib_tsan_CMakeLists.txt) = 1407f3eaa0edf1ddd13ceac8a6341a9e1f0a906b
+SHA1 (patch-lib_tsan_rtl_tsan__interceptors.cc) = e6322e4c5cdc0c052957a211079f26f49cd826d8
 SHA1 (patch-test_asan_TestCases_Posix_stack-use-after-return.cc) = 7eb1109c646b5eb4cce26140246949eb4c593a3b
 SHA1 (patch-test_asan_TestCases_heavy__uar__test.cc) = a0d7c228b02c4b5d4a198bce9ef8bc594c92544d
 SHA1 (patch-test_asan_TestCases_interception__failure__test.cc) = b4711fcc3315eaacc2a4ec1021e04b8200749e51
+SHA1 (patch-test_fuzzer_NullDerefTest.cpp) = 80b63f1c77fef2747af03c3c09a8b805ed2f27f9
 SHA1 (patch-test_fuzzer_lit.cfg) = b36c905a14ff1594dac503bc04e08f61d7e843b0
 SHA1 (patch-test_lsan_lit.common.cfg) = b09b4ab3a97dc881b701a3583b0b126b8206cfe2
 SHA1 (patch-test_scudo_lit.cfg) = 35e4f0524a8fd26e90e5d968b73d75f277da3779
diff --git a/compiler-rt-netbsd/patches/patch-lib_esan_esan__interceptors.cpp b/compiler-rt-netbsd/patches/patch-lib_esan_esan__interceptors.cpp
new file mode 100644
index 0000000000..77942803a7
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_esan_esan__interceptors.cpp
@@ -0,0 +1,26 @@
+$NetBSD$
+
+--- lib/esan/esan_interceptors.cpp.orig	2018-04-25 21:13:40.000000000 +0000
++++ lib/esan/esan_interceptors.cpp
+@@ -316,13 +316,6 @@ INTERCEPTOR(int, unlink, char *path) {
+   return REAL(unlink)(path);
+ }
+ 
+-INTERCEPTOR(int, puts, const char *s) {
+-  void *ctx;
+-  COMMON_INTERCEPTOR_ENTER(ctx, puts, s);
+-  COMMON_INTERCEPTOR_READ_RANGE(ctx, s, internal_strlen(s));
+-  return REAL(puts)(s);
+-}
+-
+ INTERCEPTOR(int, rmdir, char *path) {
+   void *ctx;
+   COMMON_INTERCEPTOR_ENTER(ctx, rmdir, path);
+@@ -495,7 +488,6 @@ void initializeInterceptors() {
+   INTERCEPT_FUNCTION(unlink);
+   INTERCEPT_FUNCTION(fread);
+   INTERCEPT_FUNCTION(fwrite);
+-  INTERCEPT_FUNCTION(puts);
+   INTERCEPT_FUNCTION(rmdir);
+ 
+   ESAN_MAYBE_INTERCEPT_SIGNAL;
diff --git a/compiler-rt-netbsd/patches/patch-lib_fuzzer_FuzzerLoop.cpp b/compiler-rt-netbsd/patches/patch-lib_fuzzer_FuzzerLoop.cpp
index 3cfc5c1461..9af3f240cd 100644
--- a/compiler-rt-netbsd/patches/patch-lib_fuzzer_FuzzerLoop.cpp
+++ b/compiler-rt-netbsd/patches/patch-lib_fuzzer_FuzzerLoop.cpp
@@ -1,8 +1,8 @@
 $NetBSD$
 
---- lib/fuzzer/FuzzerLoop.cpp.orig	2018-06-01 09:39:33.000000000 +0000
+--- lib/fuzzer/FuzzerLoop.cpp.orig	2018-06-07 08:27:17.000000000 +0000
 +++ lib/fuzzer/FuzzerLoop.cpp
-@@ -271,7 +271,7 @@ NO_SANITIZE_MEMORY
+@@ -272,7 +272,7 @@ NO_SANITIZE_MEMORY
  void Fuzzer::AlarmCallback() {
    assert(Options.UnitTimeoutSec > 0);
    // In Windows Alarm callback is executed by a different thread.
diff --git a/compiler-rt-netbsd/patches/patch-lib_interception_interception.h b/compiler-rt-netbsd/patches/patch-lib_interception_interception.h
new file mode 100644
index 0000000000..aad5e06952
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_interception_interception.h
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- lib/interception/interception.h.orig	2018-06-01 09:36:54.000000000 +0000
++++ lib/interception/interception.h
+@@ -29,6 +29,7 @@ typedef __sanitizer::uptr    SIZE_T;
+ typedef __sanitizer::sptr    SSIZE_T;
+ typedef __sanitizer::sptr    PTRDIFF_T;
+ typedef __sanitizer::s64     INTMAX_T;
++typedef __sanitizer::u64     UINTMAX_T;
+ typedef __sanitizer::OFF_T   OFF_T;
+ typedef __sanitizer::OFF64_T OFF64_T;
+ 
diff --git a/compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc b/compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc
index 4b75b64984..f2e40132db 100644
--- a/compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc
+++ b/compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/msan/msan_interceptors.cc.orig	2018-06-07 08:27:17.744691167 +0000
+--- lib/msan/msan_interceptors.cc.orig	2018-06-07 08:27:17.000000000 +0000
 +++ lib/msan/msan_interceptors.cc
 @@ -33,11 +33,13 @@
  #include "sanitizer_common/sanitizer_libc.h"
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc
index ac63cba596..c4c5edac4a 100644
--- a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc
@@ -14,7 +14,32 @@ $NetBSD$
  #define getitimer __getitimer50
  #define getpwent __getpwent50
  #define getpwnam __getpwnam50
-@@ -7190,6 +7195,303 @@ INTERCEPTOR(struct __sanitizer_netent *,
+@@ -111,6 +116,7 @@
+ #define times __times13
+ #define wait3 __wait350
+ #define wait4 __wait450
++#define getmntinfo __getmntinfo13
+ extern const unsigned short *_ctype_tab_;
+ extern const short *_toupper_tab_;
+ extern const short *_tolower_tab_;
+@@ -3301,14 +3307,14 @@ INTERCEPTOR(INTMAX_T, strtoimax, const c
+   return res;
+ }
+ 
+-INTERCEPTOR(INTMAX_T, strtoumax, const char *nptr, char **endptr, int base) {
++INTERCEPTOR(UINTMAX_T, strtoumax, const char *nptr, char **endptr, int base) {
+   void *ctx;
+   COMMON_INTERCEPTOR_ENTER(ctx, strtoumax, nptr, endptr, base);
+   // FIXME: under ASan the call below may write to freed memory and corrupt
+   // its metadata. See
+   // https://github.com/google/sanitizers/issues/321.
+   char *real_endptr;
+-  INTMAX_T res = REAL(strtoumax)(nptr, &real_endptr, base);
++  UINTMAX_T res = REAL(strtoumax)(nptr, &real_endptr, base);
+   StrtolFixAndCheck(ctx, nptr, endptr, real_endptr, base);
+   return res;
+ }
+@@ -7190,6 +7196,1085 @@ INTERCEPTOR(struct __sanitizer_netent *,
  #define INIT_NETENT
  #endif
  
@@ -314,11 +339,793 @@ $NetBSD$
 +#else
 +#define INIT_REGEX
 +#endif
++
++#if SANITIZER_INTERCEPT_STRTONUM
++INTERCEPTOR(long long, strtonum, const char * nptr, long long minval,
++	    long long maxval, const char **errstr) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, strtonum, nptr, minval, maxval, errstr);
++
++  if (nptr)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, nptr, REAL(strlen)(nptr) + 1);
++  long long ret = REAL(strtonum)(nptr, minval, maxval, errstr);
++  if (errstr) {
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, errstr, sizeof(const char *));
++    if (*errstr)
++      COMMON_INTERCEPTOR_WRITE_RANGE(ctx, *errstr, REAL(strlen)(*errstr) + 1);
++  }
++  return ret;
++}
++
++INTERCEPTOR(INTMAX_T, strtoi, const char * nptr, char ** endptr, int base,
++            INTMAX_T low, INTMAX_T high, int *rstatus) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, strtoi, nptr, endptr, base, low, high, rstatus);
++
++  if (nptr)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, nptr, REAL(strlen)(nptr) + 1);
++  INTMAX_T ret = REAL(strtoi)(nptr, endptr, base, low, high, rstatus);
++  if (endptr) {
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, endptr, sizeof(char *));
++    if (*endptr)
++      COMMON_INTERCEPTOR_WRITE_RANGE(ctx, *endptr, REAL(strlen)(*endptr) + 1);
++  }
++  if (rstatus)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, rstatus, sizeof(int));
++  return ret;
++}
++
++INTERCEPTOR(UINTMAX_T, strtou, const char * nptr, char ** endptr, int base,
++            UINTMAX_T low, UINTMAX_T high, int *rstatus) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, strtou, nptr, endptr, base, low, high, rstatus);
++
++  if (nptr)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, nptr, REAL(strlen)(nptr) + 1);
++  UINTMAX_T ret = REAL(strtou)(nptr, endptr, base, low, high, rstatus);
++  if (endptr) {
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, endptr, sizeof(char *));
++    if (*endptr)
++      COMMON_INTERCEPTOR_WRITE_RANGE(ctx, *endptr, REAL(strlen)(*endptr) + 1);
++  }
++  if (rstatus)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, rstatus, sizeof(int));
++  return ret;
++}
++
++#define INIT_STRTONUM \
++  COMMON_INTERCEPT_FUNCTION(strtonum); \
++  COMMON_INTERCEPT_FUNCTION(strtoi); \
++  COMMON_INTERCEPT_FUNCTION(strtou)
++
++#else
++#define INIT_STRTONUM
++#endif
++
++#if SANITIZER_INTERCEPT_VIS
++INTERCEPTOR(char *, vis, char *dst, int c, int flag, int nextc) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, vis, dst, c, flag, nextc);
++
++  char *end = REAL(vis)(dst, c, flag, nextc);
++  // dst is NULL terminated and end points to the NULL char
++  if (dst && end)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, end - dst + 1);
++  return end;
++}
++
++INTERCEPTOR(char *, nvis, char *dst, SIZE_T dlen, int c, int flag, int nextc) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, nvis, dst, dlen, c, flag, nextc);
++
++  char *end = REAL(nvis)(dst, dlen, c, flag, nextc);
++  // nvis cannot make sure the dst is NULL terminated
++  if (dst && end)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst,
++				   (SIZE_T)(end - dst + 1) < dlen ?
++				   end - dst + 1 : dlen);
++  return end;
++}
++
++INTERCEPTOR(int, strvis, char *dst, const char *src, int flag) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, strvis, dst, src, flag);
++  if (src)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, src, REAL(strlen)(src) + 1);
++  int len = REAL(strvis)(dst, src, flag);
++  if (dst)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, len + 1);
++  return len;
++}
++
++INTERCEPTOR(int, stravis, char **dst, const char *src, int flag) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, stravis, dst, src, flag);
++  if (src)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, src, REAL(strlen)(src) + 1);
++  int len = REAL(stravis)(dst, src, flag);
++  if (dst) {
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, sizeof(char *));
++    if (*dst)
++      COMMON_INTERCEPTOR_WRITE_RANGE(ctx, *dst, len + 1);
++  }
++  return len;
++}
++
++INTERCEPTOR(int, strnvis, char *dst, SIZE_T dlen, const char *src, int flag) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, strnvis, dst, dlen, src, flag);
++  if (src)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, src, REAL(strlen)(src) + 1);
++  int len = REAL(strnvis)(dst, dlen, src, flag);
++  // The interface will be valid even if there is no space for NULL char
++  if (dst && len >= 0)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, (SIZE_T)len + 1 < dlen ? len + 1 : dlen);
++  return len;
++}
++
++INTERCEPTOR(int, strvisx, char *dst, const char *src, SIZE_T len, int flag) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, strvisx, dst, src, len, flag);
++  if (src)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, src, len);
++  int ret = REAL(strvisx)(dst, src, len, flag);
++  if (dst)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, ret + 1);
++  return ret;
++}
++
++INTERCEPTOR(int, strnvisx, char *dst, SIZE_T dlen, const char *src, SIZE_T len, int flag) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, strnvisx, dst, dlen, src, len, flag);
++  if (src)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, src, len);
++  int ret = REAL(strnvisx)(dst, dlen, src, len, flag);
++  if (dst && ret >= 0)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, (SIZE_T)ret + 1 < dlen ? ret + 1 : dlen);
++  return ret;
++}
++
++INTERCEPTOR(int, strenvisx, char *dst, SIZE_T dlen, const char *src, SIZE_T len, int flag,
++	    int *cerr_ptr) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, strenvisx, dst, dlen, src, len, flag, cerr_ptr);
++  if (src)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, src, len);
++  // FIXME: only need to be checked when "flag | VIS_NOLOCALE" doesn't hold
++  // according to the implementation
++  if (cerr_ptr)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, cerr_ptr, sizeof(int));
++  int ret = REAL(strenvisx)(dst, dlen, src, len, flag, cerr_ptr);
++  if (dst && ret >= 0)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, (SIZE_T)ret + 1 < dlen ? ret + 1 : dlen);
++  if (cerr_ptr)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, cerr_ptr, sizeof(int));
++  return ret;
++}
++
++INTERCEPTOR(char *, svis, char *dst, int c, int flag, int nextc, const char *extra) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, svis, dst, c, flag, nextc, extra);
++  if (extra)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, extra, REAL(strlen)(extra) + 1);
++  char *end = REAL(svis)(dst, c, flag, nextc, extra);
++  if (dst && end)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, end - dst + 1);
++  return end;
++}
++
++INTERCEPTOR(char *, snvis, char *dst, SIZE_T dlen, int c, int flag, int nextc,
++	    const char *extra) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, snvis, dst, dlen, c, flag, nextc, extra);
++  if (extra)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, extra, REAL(strlen)(extra) + 1);
++  char *end = REAL(snvis)(dst, dlen, c, flag, nextc, extra);
++  if (dst && end)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst,
++				   (SIZE_T)(end - dst + 1) < dlen ? end - dst + 1 : dlen);
++  return end;
++}
++
++INTERCEPTOR(int, strsvis, char *dst, const char *src, int flag, const char *extra) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, strsvis, dst, src, flag, extra);
++  if (src)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, src, REAL(strlen)(src) + 1);
++  if (extra)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, extra, REAL(strlen)(extra) + 1);
++  int len = REAL(strsvis)(dst, src, flag, extra);
++  if (dst)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, len + 1);
++  return len;
++}
++
++INTERCEPTOR(int, strsnvis, char *dst, SIZE_T dlen, const char *src, int flag,
++	    const char *extra) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, strsnvis, dst, dlen, src, flag, extra);
++  if (src)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, src, REAL(strlen)(src) + 1);
++  if (extra)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, extra, REAL(strlen)(extra) + 1);
++  int len = REAL(strsnvis)(dst, dlen, src, flag, extra);
++  // The interface will be valid even if there is no space for NULL char
++  if (dst && len >= 0)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, (SIZE_T)len + 1 < dlen ? len + 1 : dlen);
++  return len;
++}
++
++INTERCEPTOR(int, strsvisx, char *dst, const char *src, SIZE_T len, int flag,
++	    const char *extra) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, strsvisx, dst, src, len, flag, extra);
++  if (src)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, src, len);
++  if (extra)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, extra, REAL(strlen)(extra) + 1);
++  int ret = REAL(strsvisx)(dst, src, len, flag, extra);
++  if (dst)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, ret + 1);
++  return ret;
++}
++
++INTERCEPTOR(int, strsnvisx, char *dst, SIZE_T dlen, const char *src, SIZE_T len, int flag,
++	    const char *extra) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, strsnvisx, dst, dlen, src, len, flag, extra);
++  if (src)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, src, len);
++  if (extra)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, extra, REAL(strlen)(extra) + 1);
++  int ret = REAL(strsnvisx)(dst, dlen, src, len, flag, extra);
++  if (dst && ret >= 0)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, (SIZE_T)ret + 1 < dlen ? ret + 1 : dlen);
++  return ret;
++}
++
++INTERCEPTOR(int, strsenvisx, char *dst, SIZE_T dlen, const char *src, SIZE_T len, int flag,
++	    const char *extra, int *cerr_ptr) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, strsenvisx, dst, dlen, src, len, flag, extra, cerr_ptr);
++  if (src)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, src, len);
++  if (extra)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, extra, REAL(strlen)(extra) + 1);
++  // FIXME: only need to be checked when "flag | VIS_NOLOCALE" doesn't hold
++  // according to the implementation
++  if (cerr_ptr)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, cerr_ptr, sizeof(int));
++  int ret = REAL(strsenvisx)(dst, dlen, src, len, flag, extra, cerr_ptr);
++  if (dst && ret >= 0)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, (SIZE_T)ret + 1 < dlen ? ret + 1 : dlen);
++  if (cerr_ptr)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, cerr_ptr, sizeof(int));
++  return ret;
++}
++
++INTERCEPTOR(int, unvis, char *cp, int c, int *astate, int flag) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, unvis, cp, c, astate, flag);
++  if (astate)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, astate, sizeof(*astate));
++  int ret = REAL(unvis)(cp, c, astate, flag);
++  if (ret == unvis_valid ||
++      ret == unvis_validpush) {
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, cp, sizeof(*cp));
++  }
++  return ret;
++}
++
++INTERCEPTOR(int, strunvis, char *dst, const char *src) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, strunvis, dst, src);
++  if (src)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, src, REAL(strlen)(src) + 1);
++  int ret = REAL(strunvis)(dst, src);
++  if (ret != -1)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, ret + 1);
++  return ret;
++}
++
++INTERCEPTOR(int, strnunvis, char *dst, SIZE_T dlen, const char *src) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, strnunvis, dst, dlen, src);
++  if (src)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, src, REAL(strlen)(src) + 1);
++  int ret = REAL(strnunvis)(dst, dlen, src);
++  if (ret != -1)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, (SIZE_T)ret + 1 < dlen ? ret + 1 : dlen);
++  return ret;
++}
++
++INTERCEPTOR(int, strunvisx, char *dst, const char *src, int flag) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, strunvisx, dst, src, flag);
++  if (src)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, src, REAL(strlen)(src) + 1);
++  int ret = REAL(strunvisx)(dst, src, flag);
++  if (ret != -1)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, ret + 1);
++  return ret;
++}
++
++INTERCEPTOR(int, strnunvisx, char *dst, SIZE_T dlen, const char *src, int flag) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, strnunvisx, dst, dlen, src, flag);
++  if (src)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, src, REAL(strlen)(src) + 1);
++  int ret = REAL(strnunvisx)(dst, dlen, src, flag);
++  if (ret != -1)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, (SIZE_T)ret + 1 < dlen ? ret + 1 : dlen);
++  return ret;
++}
++
++#define INIT_VIS \
++  COMMON_INTERCEPT_FUNCTION(vis); \
++  COMMON_INTERCEPT_FUNCTION(nvis); \
++  COMMON_INTERCEPT_FUNCTION(strvis); \
++  COMMON_INTERCEPT_FUNCTION(stravis); \
++  COMMON_INTERCEPT_FUNCTION(strnvis); \
++  COMMON_INTERCEPT_FUNCTION(strvisx); \
++  COMMON_INTERCEPT_FUNCTION(strnvisx); \
++  COMMON_INTERCEPT_FUNCTION(strenvisx); \
++  COMMON_INTERCEPT_FUNCTION(svis); \
++  COMMON_INTERCEPT_FUNCTION(snvis); \
++  COMMON_INTERCEPT_FUNCTION(strsvis); \
++  COMMON_INTERCEPT_FUNCTION(strsnvis); \
++  COMMON_INTERCEPT_FUNCTION(strsvisx); \
++  COMMON_INTERCEPT_FUNCTION(strsnvisx); \
++  COMMON_INTERCEPT_FUNCTION(strsenvisx); \
++  COMMON_INTERCEPT_FUNCTION(unvis); \
++  COMMON_INTERCEPT_FUNCTION(strunvis); \
++  COMMON_INTERCEPT_FUNCTION(strnunvis); \
++  COMMON_INTERCEPT_FUNCTION(strunvisx); \
++  COMMON_INTERCEPT_FUNCTION(strnunvisx)
++#else
++#define INIT_VIS
++#endif
++
++#if SANITIZER_INTERCEPT_GETMNTINFO
++INTERCEPTOR(int, getmntinfo, void **mntbufp, int flags) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, getmntinfo, mntbufp, flags);
++  int cnt = REAL(getmntinfo)(mntbufp, flags);
++  if (cnt > 0 && mntbufp) {
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, mntbufp, sizeof(void *));
++    if (*mntbufp)
++      COMMON_INTERCEPTOR_WRITE_RANGE(ctx, *mntbufp,
++				     cnt * struct_statvfs_sz);
++  }
++  return cnt;
++}
++
++#define INIT_GETMNTINFO COMMON_INTERCEPT_FUNCTION(getmntinfo)
++#else
++#define INIT_GETMNTINFO
++#endif
++
++#if SANITIZER_INTERCEPT_PUTS
++INTERCEPTOR(int, puts, const char *str) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, puts, str);
++  if (str)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, str, REAL(strlen)(str) + 1);
++  int ret = REAL(puts)(str);
++  return ret;
++}
++INTERCEPTOR(int, fputs, const char *str, __sanitizer_FILE *stream) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, fputs, str, stream);
++  if (str)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, str, REAL(strlen)(str) + 1);
++  int ret = REAL(fputs)(str, stream);
++  return ret;
++}
++#define INIT_PUTS \
++    COMMON_INTERCEPT_FUNCTION(puts); \
++    COMMON_INTERCEPT_FUNCTION(fputs)
++#else
++#define INIT_PUTS
++#endif
++
++#if SANITIZER_INTERCEPT_SHA1
++
++INTERCEPTOR(void, SHA1Init, void *context) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, SHA1Init, context);
++  REAL(SHA1Init)(context);
++  COMMON_INTERCEPTOR_WRITE_RANGE(ctx, context, SHA1_CTX_sz);
++}
++
++INTERCEPTOR(void, SHA1Update, void *context, const u8 * data, unsigned len) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, SHA1Update, context, data, len);
++  if (data)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, data, len);
++  if (context)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, context, SHA1_CTX_sz);
++  REAL(SHA1Update)(context, data, len);
++}
++
++INTERCEPTOR(void, SHA1Final, u8 digest[20], void *context) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, SHA1Final, digest, context);
++  REAL(SHA1Final)(digest, context);
++  if (digest)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, digest, sizeof(u8) * 20);
++}
++
++INTERCEPTOR(void, SHA1Transform, u32 state[5], u8 buffer[64]) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, SHA1Transform, state, buffer);
++  if (state)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, state, sizeof(u32) * 5);
++  if (buffer)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, buffer, sizeof(u8) * 64);
++  REAL(SHA1Transform)(state, buffer);
++}
++
++INTERCEPTOR(char *, SHA1End, void *context, char *buf) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, SHA1End, context, buf);
++  if (context)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, context, SHA1_CTX_sz);
++  char *ret = REAL(SHA1End)(context, buf);
++  if (ret)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, SHA1_return_length);
++  return ret;
++}
++
++INTERCEPTOR(char *, SHA1File, char *filename, char *buf) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, SHA1File, filename, buf);
++  if (filename)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, filename, REAL(strlen)(filename) + 1);
++  char *ret = REAL(SHA1File)(filename, buf);
++  if (ret)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, SHA1_return_length);
++  return ret;
++}
++
++INTERCEPTOR(char *, SHA1Data, u8 *data, SIZE_T len, char *buf) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, SHA1Data, data, len, buf);
++  if (data)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, data, len);
++  char *ret = REAL(SHA1Data)(data, len, buf);
++  if (ret)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, SHA1_return_length);
++  return ret;
++}
++
++#define INIT_SHA1 \
++  COMMON_INTERCEPT_FUNCTION(SHA1Init); \
++  COMMON_INTERCEPT_FUNCTION(SHA1Update); \
++  COMMON_INTERCEPT_FUNCTION(SHA1Final); \
++  COMMON_INTERCEPT_FUNCTION(SHA1Transform); \
++  COMMON_INTERCEPT_FUNCTION(SHA1End); \
++  COMMON_INTERCEPT_FUNCTION(SHA1File); \
++  COMMON_INTERCEPT_FUNCTION(SHA1Data)
++#else
++#define INIT_SHA1
++#endif
++
++#if SANITIZER_INTERCEPT_MD2
++
++INTERCEPTOR(void, MD2Init, void *context) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, MD2Init, context);
++  REAL(MD2Init)(context);
++  COMMON_INTERCEPTOR_WRITE_RANGE(ctx, context, MD2_CTX_sz);
++}
++
++INTERCEPTOR(void, MD2Update, void *context, const unsigned char *data,
++            unsigned int len) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, MD2Update, context, data, len);
++  if (data)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, data, len);
++  if (context)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, context, MD2_CTX_sz);
++  REAL(MD2Update)(context, data, len);
++}
++
++INTERCEPTOR(void, MD2Final, unsigned char digest[16], void *context) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, MD2Final, digest, context);
++  REAL(MD2Final)(digest, context);
++  if (digest)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, digest, sizeof(unsigned char) * 16);
++}
++
++INTERCEPTOR(char *, MD2End, void *context, char *buf) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, MD2End, context, buf);
++  if (context)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, context, MD2_CTX_sz);
++  char *ret = REAL(MD2End)(context, buf);
++  if (ret)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, MD2_return_length);
++  return ret;
++}
++
++INTERCEPTOR(char *, MD2File, const char *filename, char *buf) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, MD2File, filename, buf);
++  if (filename)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, filename, REAL(strlen)(filename) + 1);
++  char *ret = REAL(MD2File)(filename, buf);
++  if (ret)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, MD2_return_length);
++  return ret;
++}
++
++INTERCEPTOR(char *, MD2Data, const unsigned char *data, unsigned int len, char *buf) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, MD2Data, data, len, buf);
++  if (data)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, data, len);
++  char *ret = REAL(MD2Data)(data, len, buf);
++  if (ret)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, MD2_return_length);
++  return ret;
++}
++
++#define INIT_MD2 \
++  COMMON_INTERCEPT_FUNCTION(MD2Init); \
++  COMMON_INTERCEPT_FUNCTION(MD2Update); \
++  COMMON_INTERCEPT_FUNCTION(MD2Final); \
++  COMMON_INTERCEPT_FUNCTION(MD2End); \
++  COMMON_INTERCEPT_FUNCTION(MD2File); \
++  COMMON_INTERCEPT_FUNCTION(MD2Data)
++#else
++#define INIT_MD2
++#endif
++
++#if SANITIZER_INTERCEPT_MD4
++
++INTERCEPTOR(void, MD4Init, void *context) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, MD4Init, context);
++  REAL(MD4Init)(context);
++  COMMON_INTERCEPTOR_WRITE_RANGE(ctx, context, MD4_CTX_sz);
++}
++
++INTERCEPTOR(void, MD4Update, void *context, const unsigned char *data,
++            unsigned int len) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, MD4Update, context, data, len);
++  if (data)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, data, len);
++  if (context)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, context, MD4_CTX_sz);
++  REAL(MD4Update)(context, data, len);
++}
++
++INTERCEPTOR(void, MD4Final, unsigned char digest[16], void *context) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, MD4Final, digest, context);
++  REAL(MD4Final)(digest, context);
++  if (digest)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, digest, sizeof(unsigned char) * 16);
++}
++
++INTERCEPTOR(char *, MD4End, void *context, char *buf) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, MD4End, context, buf);
++  if (context)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, context, MD4_CTX_sz);
++  char *ret = REAL(MD4End)(context, buf);
++  if (ret)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, MD4_return_length);
++  return ret;
++}
++
++INTERCEPTOR(char *, MD4File, const char *filename, char *buf) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, MD4File, filename, buf);
++  if (filename)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, filename, REAL(strlen)(filename) + 1);
++  char *ret = REAL(MD4File)(filename, buf);
++  if (ret)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, MD4_return_length);
++  return ret;
++}
++
++INTERCEPTOR(char *, MD4Data, const unsigned char *data, unsigned int len, char *buf) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, MD4Data, data, len, buf);
++  if (data)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, data, len);
++  char *ret = REAL(MD4Data)(data, len, buf);
++  if (ret)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, MD4_return_length);
++  return ret;
++}
++
++#define INIT_MD4 \
++  COMMON_INTERCEPT_FUNCTION(MD4Init); \
++  COMMON_INTERCEPT_FUNCTION(MD4Update); \
++  COMMON_INTERCEPT_FUNCTION(MD4Final); \
++  COMMON_INTERCEPT_FUNCTION(MD4End); \
++  COMMON_INTERCEPT_FUNCTION(MD4File); \
++  COMMON_INTERCEPT_FUNCTION(MD4Data)
++#else
++#define INIT_MD4
++#endif
++
++#if SANITIZER_INTERCEPT_MD5
++
++INTERCEPTOR(void, MD5Init, void *context) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, MD5Init, context);
++  REAL(MD5Init)(context);
++  COMMON_INTERCEPTOR_WRITE_RANGE(ctx, context, MD5_CTX_sz);
++}
++
++INTERCEPTOR(void, MD5Update, void *context, const unsigned char *data,
++            unsigned int len) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, MD5Update, context, data, len);
++  if (data)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, data, len);
++  if (context)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, context, MD5_CTX_sz);
++  REAL(MD5Update)(context, data, len);
++}
++
++INTERCEPTOR(void, MD5Final, unsigned char digest[16], void *context) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, MD5Final, digest, context);
++  REAL(MD5Final)(digest, context);
++  if (digest)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, digest, sizeof(unsigned char) * 16);
++}
++
++INTERCEPTOR(char *, MD5End, void *context, char *buf) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, MD5End, context, buf);
++  if (context)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, context, MD5_CTX_sz);
++  char *ret = REAL(MD5End)(context, buf);
++  if (ret)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, MD5_return_length);
++  return ret;
++}
++
++INTERCEPTOR(char *, MD5File, const char *filename, char *buf) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, MD5File, filename, buf);
++  if (filename)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, filename, REAL(strlen)(filename) + 1);
++  char *ret = REAL(MD5File)(filename, buf);
++  if (ret)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, MD5_return_length);
++  return ret;
++}
++
++INTERCEPTOR(char *, MD5Data, const unsigned char *data, unsigned int len, char *buf) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, MD5Data, data, len, buf);
++  if (data)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, data, len);
++  char *ret = REAL(MD5Data)(data, len, buf);
++  if (ret)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, MD5_return_length);
++  return ret;
++}
++
++#define INIT_MD5 \
++  COMMON_INTERCEPT_FUNCTION(MD5Init); \
++  COMMON_INTERCEPT_FUNCTION(MD5Update); \
++  COMMON_INTERCEPT_FUNCTION(MD5Final); \
++  COMMON_INTERCEPT_FUNCTION(MD5End); \
++  COMMON_INTERCEPT_FUNCTION(MD5File); \
++  COMMON_INTERCEPT_FUNCTION(MD5Data)
++#else
++#define INIT_MD5
++#endif
++
++#if SANITIZER_INTERCEPT_GETVFSSTAT
++INTERCEPTOR(int, getvfsstat, void *buf, SIZE_T bufsize, int flags) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, getvfsstat, buf, bufsize, flags);
++  int ret = REAL(getvfsstat)(buf, bufsize, flags);
++  if (buf && ret > 0)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, buf, ret * struct_statvfs_sz);
++  return ret;
++}
++#define INIT_GETVFSSTAT COMMON_INTERCEPT_FUNCTION(getvfsstat)
++#else
++#define INIT_GETVFSSTAT
++#endif
++
++#if SANITIZER_INTERCEPT_NL_LANGINFO
++INTERCEPTOR(char *, nl_langinfo, long item) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, nl_langinfo, item);
++  char *ret = REAL(nl_langinfo)(item);
++  if (ret)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, REAL(strlen)(ret) + 1);
++  return ret;
++}
++#define INIT_NL_LANGINFO COMMON_INTERCEPT_FUNCTION(nl_langinfo)
++#else
++#define INIT_NL_LANGINFO
++#endif
++
++#if SANITIZER_INTERCEPT_FPARSELN
++INTERCEPTOR(char *, fparseln, __sanitizer_FILE *stream, SIZE_T *len, SIZE_T *lineno,
++            const char delim[3], int flags) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, fparseln, stream, len, lineno, delim, flags);
++  if (len)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, len, sizeof(*len));
++  if (lineno)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, lineno, sizeof(*lineno));
++  if (delim)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, delim, sizeof(delim[0]) * 3);
++  char *ret = REAL(fparseln)(stream, len, lineno, delim, flags);
++  if (ret)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, REAL(strlen)(ret) + 1);
++  return ret;
++}
++#define INIT_FPARSELN COMMON_INTERCEPT_FUNCTION(fparseln)
++#else
++#define INIT_FPARSELN
++#endif
++
++#if SANITIZER_INTERCEPT_MODCTL
++INTERCEPTOR(int, modctl, int operation, void *argp) {
++  void *ctx;
++  int ret;
++  COMMON_INTERCEPTOR_ENTER(ctx, modctl, operation, argp);
++
++  if (operation == modctl_load) {
++    if (argp) {
++      __sanitizer_modctl_load_t *ml = (__sanitizer_modctl_load_t *)argp;
++      COMMON_INTERCEPTOR_READ_RANGE(ctx, ml, sizeof(*ml));
++      if (ml->ml_filename)
++        COMMON_INTERCEPTOR_READ_RANGE(ctx, ml->ml_filename,
++                                      REAL(strlen)(ml->ml_filename) + 1);
++      if (ml->ml_props)
++        COMMON_INTERCEPTOR_READ_RANGE(ctx, ml->ml_props, ml->ml_propslen);
++    }
++    ret = REAL(modctl)(operation, argp);
++  } else if (operation == modctl_unload) {
++    if (argp) {
++      const char *name = (const char *)argp;
++      COMMON_INTERCEPTOR_READ_RANGE(ctx, name, REAL(strlen)(name) + 1);
++    }
++    ret = REAL(modctl)(operation, argp);
++  } else if (operation == modctl_stat) {
++    uptr iov_len;
++    struct __sanitizer_iovec *iov = (struct __sanitizer_iovec *)argp;
++    if (iov) {
++      COMMON_INTERCEPTOR_READ_RANGE(ctx, iov, sizeof(*iov));
++      iov_len = iov->iov_len;
++    }
++    ret = REAL(modctl)(operation, argp);
++    if (iov)
++      COMMON_INTERCEPTOR_WRITE_RANGE(ctx, iov->iov_base,
++                                     iov_len < iov->iov_len ? iov_len : iov->iov_len);
++  } else if (operation == modctl_exists)
++    ret = REAL(modctl)(operation, argp);
++  else
++    ret = REAL(modctl)(operation, argp);
++
++  return ret;
++}
++#define INIT_MODCTL COMMON_INTERCEPT_FUNCTION(modctl)
++#else
++#define INIT_MODCTL
++#endif
 +
  static void InitializeCommonInterceptors() {
    static u64 metadata_mem[sizeof(MetadataHashMap) / sizeof(u64) + 1];
    interceptor_metadata_map = new((void *)&metadata_mem) MetadataHashMap();
-@@ -7436,6 +7738,10 @@ static void InitializeCommonInterceptors
+@@ -7436,6 +8521,22 @@ static void InitializeCommonInterceptors
    INIT_TTYENT;
    INIT_PROTOENT;
    INIT_NETENT;
@@ -326,6 +1133,18 @@ $NetBSD$
 +  INIT_ATOF;
 +  INIT_FTS;
 +  INIT_REGEX;
++  INIT_STRTONUM;
++  INIT_VIS;
++  INIT_GETMNTINFO;
++  INIT_PUTS;
++  INIT_SHA1;
++  INIT_MD2;
++  INIT_MD4;
++  INIT_MD5;
++  INIT_GETVFSSTAT;
++  INIT_NL_LANGINFO;
++  INIT_FPARSELN;
++  INIT_MODCTL;
  
    INIT___PRINTF_CHK;
  }
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.cc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
index 6142aa036b..b336d7d19e 100644
--- a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_linux.cc.orig	2018-06-01 09:39:33.000000000 +0000
+--- lib/sanitizer_common/sanitizer_linux.cc.orig	2018-06-07 08:27:17.000000000 +0000
 +++ lib/sanitizer_common/sanitizer_linux.cc
 @@ -93,6 +93,7 @@ extern "C" {
  
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc
deleted file mode 100644
index 40c788e70c..0000000000
--- a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc
+++ /dev/null
@@ -1,12 +0,0 @@
-$NetBSD$
-
---- lib/sanitizer_common/sanitizer_linux_libcdep.cc.orig	2018-05-10 23:16:36.000000000 +0000
-+++ lib/sanitizer_common/sanitizer_linux_libcdep.cc
-@@ -47,6 +47,7 @@
- #endif
- 
- #if SANITIZER_NETBSD
-+#define sysctl _sysctl
- #include <sys/sysctl.h>
- #include <sys/tls.h>
- #endif
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h
index 8fce680db1..12a5f5db50 100644
--- a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h
@@ -1,8 +1,8 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_platform_interceptors.h.orig	2018-06-01 09:36:54.000000000 +0000
+--- lib/sanitizer_common/sanitizer_platform_interceptors.h.orig	2018-06-06 19:08:28.000000000 +0000
 +++ lib/sanitizer_common/sanitizer_platform_interceptors.h
-@@ -498,4 +498,9 @@
+@@ -507,4 +507,21 @@
  #define SANITIZER_INTERCEPT_PROTOENT SI_NETBSD
  #define SANITIZER_INTERCEPT_NETENT SI_NETBSD
  
@@ -10,5 +10,17 @@ $NetBSD$
 +#define SANITIZER_INTERCEPT_ATOF SI_NETBSD
 +#define SANITIZER_INTERCEPT_FTS SI_NETBSD
 +#define SANITIZER_INTERCEPT_REGEX SI_NETBSD
++#define SANITIZER_INTERCEPT_STRTONUM SI_NETBSD
++#define SANITIZER_INTERCEPT_VIS SI_NETBSD
++#define SANITIZER_INTERCEPT_GETMNTINFO SI_NETBSD
++#define SANITIZER_INTERCEPT_PUTS SI_POSIX
++#define SANITIZER_INTERCEPT_SHA1 SI_NETBSD
++#define SANITIZER_INTERCEPT_MD2 SI_NETBSD
++#define SANITIZER_INTERCEPT_MD4 SI_NETBSD
++#define SANITIZER_INTERCEPT_MD5 SI_NETBSD
++#define SANITIZER_INTERCEPT_GETVFSSTAT SI_NETBSD
++#define SANITIZER_INTERCEPT_NL_LANGINFO SI_POSIX
++#define SANITIZER_INTERCEPT_FPARSELN SI_POSIX
++#define SANITIZER_INTERCEPT_MODCTL SI_NETBSD
 +
  #endif  // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.cc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.cc
index aeb788a548..6c57eb6efb 100644
--- a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.cc
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.cc
@@ -26,8 +26,37 @@ $NetBSD$
  #include <dev/biovar.h>
  #include <dev/bluetooth/btdev.h>
  #include <dev/bluetooth/btsco.h>
-@@ -204,6 +209,10 @@
+@@ -115,6 +120,9 @@
+ #include <dev/vndvar.h>
+ #include <dev/wscons/wsconsio.h>
+ #include <dev/wscons/wsdisplay_usl_io.h>
++#include <md2.h>
++#include <md4.h>
++#include <md5.h>
+ #include <net/bpf.h>
+ #include <net/if_atm.h>
+ #include <net/if_gre.h>
+@@ -173,6 +181,7 @@
+ #include <sys/filio.h>
+ #include <sys/ipc.h>
+ #include <sys/mman.h>
++#include <sys/module.h>
+ #include <sys/mount.h>
+ #include <sys/mqueue.h>
+ #include <sys/msg.h>
+@@ -180,6 +189,7 @@
+ #include <sys/ptrace.h>
+ #include <sys/resource.h>
+ #include <sys/sem.h>
++#include <sys/sha1.h>
+ #include <sys/shm.h>
+ #include <sys/signal.h>
+ #include <sys/socket.h>
+@@ -202,8 +212,13 @@
+ #include <utime.h>
+ #include <utmp.h>
  #include <utmpx.h>
++#include <vis.h>
  #include <wchar.h>
  #include <wordexp.h>
 +#include <ttyent.h>
@@ -37,7 +66,7 @@ $NetBSD$
  
  // Include these after system headers to avoid name clashes and ambiguities.
  #include "sanitizer_internal_defs.h"
-@@ -238,6 +247,10 @@ unsigned struct_rlimit_sz = sizeof(struc
+@@ -238,6 +253,10 @@ unsigned struct_rlimit_sz = sizeof(struc
  unsigned struct_timespec_sz = sizeof(struct timespec);
  unsigned struct_sembuf_sz = sizeof(struct sembuf);
  unsigned struct_kevent_sz = sizeof(struct kevent);
@@ -48,3 +77,25 @@ $NetBSD$
  unsigned struct_utimbuf_sz = sizeof(struct utimbuf);
  unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
  unsigned struct_timex_sz = sizeof(struct timex);
+@@ -2063,6 +2082,21 @@ unsigned IOCTL_SNDCTL_DSP_SILENCE = SNDC
+ 
+ const int si_SEGV_MAPERR = SEGV_MAPERR;
+ const int si_SEGV_ACCERR = SEGV_ACCERR;
++
++unsigned SHA1_CTX_sz = sizeof(SHA1_CTX);
++unsigned SHA1_return_length = 41;
++unsigned MD2_CTX_sz = sizeof(MD2_CTX);
++unsigned MD2_return_length = 33;
++unsigned MD4_CTX_sz = sizeof(MD4_CTX);
++unsigned MD4_return_length = 33;
++unsigned MD5_CTX_sz = sizeof(MD5_CTX);
++unsigned MD5_return_length = 33;
++int unvis_valid = UNVIS_VALID;
++int unvis_validpush = UNVIS_VALIDPUSH;
++int modctl_load = MODCTL_LOAD;
++int modctl_unload = MODCTL_UNLOAD;
++int modctl_stat = MODCTL_STAT;
++int modctl_exists = MODCTL_EXISTS;
+ }  // namespace __sanitizer
+ 
+ using namespace __sanitizer;
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h
index fae45776eb..ed479cac86 100644
--- a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h
@@ -26,3 +26,32 @@ $NetBSD$
  struct __sanitizer_ptrace_io_desc {
    int piod_op;
    void *piod_offs;
+@@ -2194,6 +2204,28 @@ extern unsigned IOCTL_SNDCTL_DSP_SILENCE
+ 
+ extern const int si_SEGV_MAPERR;
+ extern const int si_SEGV_ACCERR;
++
++extern unsigned SHA1_CTX_sz;
++extern unsigned SHA1_return_length;
++extern unsigned MD2_CTX_sz;
++extern unsigned MD2_return_length;
++extern unsigned MD4_CTX_sz;
++extern unsigned MD4_return_length;
++extern unsigned MD5_CTX_sz;
++extern unsigned MD5_return_length;
++extern int unvis_valid;
++extern int unvis_validpush;
++
++typedef struct __sanitizer_modctl_load {
++  const char *ml_filename;
++  int ml_flags;
++  const char *ml_props;
++  uptr ml_propslen;
++} __sanitizer_modctl_load_t;
++extern int modctl_load;
++extern int modctl_unload;
++extern int modctl_stat;
++extern int modctl_exists;
+ }  // namespace __sanitizer
+ 
+ #define CHECK_TYPE_SIZE(TYPE) \
diff --git a/compiler-rt-netbsd/patches/patch-lib_tsan_CMakeLists.txt b/compiler-rt-netbsd/patches/patch-lib_tsan_CMakeLists.txt
new file mode 100644
index 0000000000..ccd0e16cb7
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_tsan_CMakeLists.txt
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- lib/tsan/CMakeLists.txt.orig	2018-04-25 21:13:39.000000000 +0000
++++ lib/tsan/CMakeLists.txt
+@@ -206,7 +206,7 @@ endif()
+ # in the base system due to incompatibilities between FreeBSD's and Clang's
+ # versions. As a workaround do not use --sysroot=. on FreeBSD until this is
+ # addressed.
+-if(COMPILER_RT_HAS_SYSROOT_FLAG AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
++if(COMPILER_RT_HAS_SYSROOT_FLAG AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD" AND NOT CMAKE_SYSTEM_NAME MATCHES "NetBSD")
+   file(GLOB _tsan_generic_sources rtl/tsan*)
+   file(GLOB _tsan_platform_sources rtl/tsan*posix* rtl/tsan*mac*
+                                    rtl/tsan*linux*)
diff --git a/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc b/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc
new file mode 100644
index 0000000000..8583e9da15
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc
@@ -0,0 +1,25 @@
+$NetBSD$
+
+--- lib/tsan/rtl/tsan_interceptors.cc.orig	2018-06-06 19:08:28.000000000 +0000
++++ lib/tsan/rtl/tsan_interceptors.cc
+@@ -1736,12 +1736,6 @@ TSAN_INTERCEPTOR(void, abort, int fake) 
+   REAL(abort)(fake);
+ }
+ 
+-TSAN_INTERCEPTOR(int, puts, const char *s) {
+-  SCOPED_TSAN_INTERCEPTOR(puts, s);
+-  MemoryAccessRange(thr, pc, (uptr)s, internal_strlen(s), false);
+-  return REAL(puts)(s);
+-}
+-
+ TSAN_INTERCEPTOR(int, rmdir, char *path) {
+   SCOPED_TSAN_INTERCEPTOR(rmdir, path);
+   Release(thr, pc, Dir2addr(path));
+@@ -2709,7 +2703,6 @@ void InitializeInterceptors() {
+   TSAN_INTERCEPT(fread);
+   TSAN_INTERCEPT(fwrite);
+   TSAN_INTERCEPT(abort);
+-  TSAN_INTERCEPT(puts);
+   TSAN_INTERCEPT(rmdir);
+   TSAN_INTERCEPT(closedir);
+ 
diff --git a/compiler-rt-netbsd/patches/patch-test_fuzzer_NullDerefTest.cpp b/compiler-rt-netbsd/patches/patch-test_fuzzer_NullDerefTest.cpp
new file mode 100644
index 0000000000..5e634639aa
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-test_fuzzer_NullDerefTest.cpp
@@ -0,0 +1,9 @@
+$NetBSD$
+
+--- test/fuzzer/NullDerefTest.cpp.orig	2018-06-07 08:27:17.000000000 +0000
++++ test/fuzzer/NullDerefTest.cpp
+@@ -23,4 +23,3 @@ extern "C" int LLVMFuzzerTestOneInput(co
+   }
+   return 0;
+ }
+-



Home | Main Index | Thread Index | Old Index