diff options
3 files changed, 23 insertions, 0 deletions
diff --git a/compiler-rt/lib/msan/lit_tests/Linux/glob.cc b/compiler-rt/lib/msan/lit_tests/Linux/glob.cc index 513679c6d3d..387ce3cf5f1 100644 --- a/compiler-rt/lib/msan/lit_tests/Linux/glob.cc +++ b/compiler-rt/lib/msan/lit_tests/Linux/glob.cc @@ -1,4 +1,5 @@ // RUN: %clangxx_msan -m64 -O0 %s -o %t && %t %p 2>&1 | FileCheck %s +// RUN: %clangxx_msan -m64 -O0 -D_FILE_OFFSET_BITS=64 %s -o %t && %t %p 2>&1 | FileCheck %s // RUN: %clangxx_msan -m64 -O3 %s -o %t && %t %p 2>&1 | FileCheck %s #include <assert.h> diff --git a/compiler-rt/lib/msan/lit_tests/Linux/glob_altdirfunc.cc b/compiler-rt/lib/msan/lit_tests/Linux/glob_altdirfunc.cc index 45a3818d17e..b8200c3ee89 100644 --- a/compiler-rt/lib/msan/lit_tests/Linux/glob_altdirfunc.cc +++ b/compiler-rt/lib/msan/lit_tests/Linux/glob_altdirfunc.cc @@ -1,4 +1,5 @@ // RUN: %clangxx_msan -m64 -O0 %s -o %t && %t %p 2>&1 | FileCheck %s +// RUN: %clangxx_msan -m64 -O0 -D_FILE_OFFSET_BITS=64 %s -o %t && %t %p 2>&1 | FileCheck %s // RUN: %clangxx_msan -m64 -O3 %s -o %t && %t %p 2>&1 | FileCheck %s #include <assert.h> diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc index ca915ba735a..0a9405fdad6 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -818,7 +818,28 @@ INTERCEPTOR(int, glob64, const char *pattern, int flags, __sanitizer_glob_t *pglob) { void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, glob64, pattern, flags, errfunc, pglob); + __sanitizer_glob_t glob_copy = {0, 0, 0, 0, wrapped_gl_closedir, + wrapped_gl_readdir, wrapped_gl_opendir, + wrapped_gl_lstat, wrapped_gl_stat}; + if (flags & glob_altdirfunc) { + Swap(pglob->gl_closedir, glob_copy.gl_closedir); + Swap(pglob->gl_readdir, glob_copy.gl_readdir); + Swap(pglob->gl_opendir, glob_copy.gl_opendir); + Swap(pglob->gl_lstat, glob_copy.gl_lstat); + Swap(pglob->gl_stat, glob_copy.gl_stat); + pglob_copy = &glob_copy; + glob_ctx = ctx; + } int res = REAL(glob64)(pattern, flags, errfunc, pglob); + if (flags & glob_altdirfunc) { + Swap(pglob->gl_closedir, glob_copy.gl_closedir); + Swap(pglob->gl_readdir, glob_copy.gl_readdir); + Swap(pglob->gl_opendir, glob_copy.gl_opendir); + Swap(pglob->gl_lstat, glob_copy.gl_lstat); + Swap(pglob->gl_stat, glob_copy.gl_stat); + } + pglob_copy = 0; + glob_ctx = 0; if ((!res || res == glob_nomatch) && pglob) unpoison_glob_t(ctx, pglob); return res; } |

