[compiler-rt] r185935 - [sanitizer] Update glob64 interceptor to handle GLOB_ALTDIRFUNC as well.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Tue Jul 9 05:34:25 PDT 2013
Author: eugenis
Date: Tue Jul 9 07:34:25 2013
New Revision: 185935
URL: http://llvm.org/viewvc/llvm-project?rev=185935&view=rev
Log:
[sanitizer] Update glob64 interceptor to handle GLOB_ALTDIRFUNC as well.
Modified:
compiler-rt/trunk/lib/msan/lit_tests/Linux/glob.cc
compiler-rt/trunk/lib/msan/lit_tests/Linux/glob_altdirfunc.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
Modified: compiler-rt/trunk/lib/msan/lit_tests/Linux/glob.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/lit_tests/Linux/glob.cc?rev=185935&r1=185934&r2=185935&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/lit_tests/Linux/glob.cc (original)
+++ compiler-rt/trunk/lib/msan/lit_tests/Linux/glob.cc Tue Jul 9 07:34:25 2013
@@ -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>
Modified: compiler-rt/trunk/lib/msan/lit_tests/Linux/glob_altdirfunc.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/lit_tests/Linux/glob_altdirfunc.cc?rev=185935&r1=185934&r2=185935&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/lit_tests/Linux/glob_altdirfunc.cc (original)
+++ compiler-rt/trunk/lib/msan/lit_tests/Linux/glob_altdirfunc.cc Tue Jul 9 07:34:25 2013
@@ -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>
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=185935&r1=185934&r2=185935&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Tue Jul 9 07:34:25 2013
@@ -818,7 +818,28 @@ INTERCEPTOR(int, glob64, const char *pat
__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;
}
More information about the llvm-commits
mailing list