[ASan] Define an internal implementation of strchr to make stack OOB tests pass on Windows

llvm-svn: 150499
This commit is contained in:
Timur Iskhodzhanov 2012-02-14 19:33:04 +00:00
parent bce36774f0
commit d2a9075de0
3 changed files with 12 additions and 1 deletions

View File

@ -120,6 +120,16 @@ size_t internal_strnlen(const char *s, size_t maxlen) {
return i;
}
char* internal_strchr(const char *s, int c) {
while (true) {
if (*s == (char)c)
return (char*)s;
if (*s == 0)
return NULL;
s++;
}
}
void* internal_memchr(const void* s, int c, size_t n) {
const char* t = (char*)s;
for (size_t i = 0; i < n; ++i, ++t)

View File

@ -33,6 +33,7 @@ namespace __asan {
// __asan::internal_X() is the implementation of X() for use in RTL.
size_t internal_strlen(const char *s);
size_t internal_strnlen(const char *s, size_t maxlen);
char* internal_strchr(const char *s, int c);
void* internal_memchr(const void* s, int c, size_t n);
int internal_memcmp(const void* s1, const void* s2, size_t n);
char *internal_strstr(const char *haystack, const char *needle);

View File

@ -159,7 +159,7 @@ static bool DescribeStackAddress(uintptr_t addr, uintptr_t access_size) {
// where alloc_i looks like "offset size len ObjectName ".
CHECK(frame_descr);
// Report the function name and the offset.
const char *name_end = REAL(strchr)(frame_descr, ' ');
const char *name_end = internal_strchr(frame_descr, ' ');
CHECK(name_end);
buf[0] = 0;
internal_strncat(buf, frame_descr,