Revert r179012: "[msan] Intercept glob()."

This was committed without tests and contains obvious bugs. That's not
acceptable. It broke address sanitizer for most programs using glob(3).

llvm-svn: 179054
This commit is contained in:
Chandler Carruth 2013-04-08 20:59:44 +00:00
parent 2eb1c57b9d
commit 2b3c00eec7
4 changed files with 1 additions and 54 deletions

View File

@ -549,53 +549,6 @@ INTERCEPTOR(int, setitimer, int which, const void *new_value, void *old_value) {
#endif
#if SANITIZER_INTERCEPT_GLOB
struct sanitizer_glob_t {
SIZE_T gl_pathc;
char **gl_pathv;
};
static void unpoison_glob_t(void *ctx, sanitizer_glob_t *pglob) {
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, pglob, sizeof(*pglob));
// +1 for NULL pointer at the end.
COMMON_INTERCEPTOR_WRITE_RANGE(
ctx, pglob->gl_pathv,
(sizeof(pglob->gl_pathc) + 1) * sizeof(*pglob->gl_pathv));
for (SIZE_T i = 0; i < pglob->gl_pathc; ++i) {
char *p = pglob->gl_pathv[i];
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, p, REAL(strlen)(p) + 1);
}
}
INTERCEPTOR(int, glob, const char *pattern, int flags,
int (*errfunc)(const char *epath, int eerrno),
sanitizer_glob_t *pglob) {
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, glob, pattern, flags, errfunc, pglob);
int res = REAL(glob)(pattern, flags, errfunc, pglob);
if (res == 0)
unpoison_glob_t(ctx, pglob);
return res;
}
INTERCEPTOR(int, glob64, const char *pattern, int flags,
int (*errfunc)(const char *epath, int eerrno),
sanitizer_glob_t *pglob) {
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, glob64, pattern, flags, errfunc, pglob);
int res = REAL(glob64)(pattern, flags, errfunc, pglob);
if (res == 0)
unpoison_glob_t(ctx, pglob);
return res;
}
#define INIT_GLOB \
INTERCEPT_FUNCTION(glob); \
INTERCEPT_FUNCTION(glob64);
#else // SANITIZER_INTERCEPT_GLOB
#define INIT_GLOB
#endif // SANITIZER_INTERCEPT_GLOB
#define SANITIZER_COMMON_INTERCEPTORS_INIT \
INIT_STRCASECMP; \
INIT_STRNCASECMP; \
@ -614,5 +567,4 @@ INTERCEPTOR(int, glob64, const char *pattern, int flags,
INIT_GETPWNAM_R_GETPWUID_R; \
INIT_CLOCK_GETTIME; \
INIT_GETITIMER; \
INIT_TIME; \
INIT_GLOB;
INIT_TIME;

View File

@ -64,4 +64,3 @@
# define SANITIZER_INTERCEPT_CLOCK_GETTIME SI_LINUX
# define SANITIZER_INTERCEPT_GETITIMER SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_TIME SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_GLOB SI_LINUX_NOT_ANDROID

View File

@ -297,8 +297,6 @@ void StatOutput(u64 *stat) {
name[StatInt_getitimer] = " getitimer ";
name[StatInt_setitimer] = " setitimer ";
name[StatInt_time] = " time ";
name[StatInt_glob] = " glob ";
name[StatInt_glob64] = " glob64 ";
name[StatAnnotation] = "Dynamic annotations ";
name[StatAnnotateHappensBefore] = " HappensBefore ";

View File

@ -292,8 +292,6 @@ enum StatType {
StatInt_getitimer,
StatInt_setitimer,
StatInt_time,
StatInt_glob,
StatInt_glob64,
// Dynamic annotations.
StatAnnotation,