summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_common_interceptors.inc
diff options
context:
space:
mode:
authorDavid Carlier <devnexen@gmail.com>2019-01-11 05:53:09 +0000
committerDavid Carlier <devnexen@gmail.com>2019-01-11 05:53:09 +0000
commit969bbb9cd5bc1401df9878af4fce201d1e928387 (patch)
treeb5e208636f1f1628d2ed7fb570b8a254139dabbd /lib/sanitizer_common/sanitizer_common_interceptors.inc
parentda0fc92a812844d3332789a407ec74131026f7e1 (diff)
downloadcompiler-rt-969bbb9cd5bc1401df9878af4fce201d1e928387.tar.gz
[Sanitizer] Intercept getusershell
- If entries are properly copied (there were a bug in FreeBSD implementation in earlier version), or list properly reset. Reviewers: vitalybuka, krytarowski Reviewed By: krytarowski Differential Revision: https://reviews.llvm.org/D56562 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@350919 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_common_interceptors.inc')
-rw-r--r--lib/sanitizer_common/sanitizer_common_interceptors.inc16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_common_interceptors.inc b/lib/sanitizer_common/sanitizer_common_interceptors.inc
index 252f55552..f3ea863bd 100644
--- a/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -9399,6 +9399,21 @@ INTERCEPTOR(char *, fdevname_r, int fd, char *buf, SIZE_T len) {
#define INIT_FDEVNAME
#endif
+#if SANITIZER_INTERCEPT_GETUSERSHELL
+INTERCEPTOR(char *, getusershell) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, getusershell);
+ char *res = REAL(getusershell)();
+ if (res)
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, res, REAL(strlen)(res) + 1);
+ return res;
+}
+
+#define INIT_GETUSERSHELL COMMON_INTERCEPT_FUNCTION(getusershell);
+#else
+#define INIT_GETUSERSHELL
+#endif
+
static void InitializeCommonInterceptors() {
static u64 metadata_mem[sizeof(MetadataHashMap) / sizeof(u64) + 1];
interceptor_metadata_map =
@@ -9687,6 +9702,7 @@ static void InitializeCommonInterceptors() {
INIT_FUNOPEN;
INIT_FUNOPEN2;
INIT_FDEVNAME;
+ INIT_GETUSERSHELL;
INIT___PRINTF_CHK;
}