diff options
| author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-07-09 12:34:25 +0000 |
|---|---|---|
| committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-07-09 12:34:25 +0000 |
| commit | 7160fb65113b20a31a410e376797a5c99cff5167 (patch) | |
| tree | 4a42f6fd5267fc7f2cef37e04e01593bb807ee58 | |
| parent | 86fbebd3b7322c9a93ae8fcc9fe34785bd71f65a (diff) | |
| download | bcm5719-llvm-7160fb65113b20a31a410e376797a5c99cff5167.tar.gz bcm5719-llvm-7160fb65113b20a31a410e376797a5c99cff5167.zip | |
[sanitizer] Update glob64 interceptor to handle GLOB_ALTDIRFUNC as well.
llvm-svn: 185935
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; } |

