[llvm-commits] [ASan] Define an internal implementation of strchr to make stack OOB tests pass (issue 5668047)
timurrrr at google.com
timurrrr at google.com
Tue Feb 14 09:47:16 PST 2012
Reviewers: kcc1,
Message:
Hi Kostya,
Can you please review this small patch?
Thanks!
Description:
Define an internal implementation of strchr to make stack OOB tests pass
Please review this at http://codereview.appspot.com/5668047/
Affected files:
M lib/asan/asan_interceptors.cc
M lib/asan/asan_rtl.cc
Index: lib/asan/asan_interceptors.cc
diff --git a/lib/asan/asan_interceptors.cc b/lib/asan/asan_interceptors.cc
index
b2d437590e9bccbdccf8f0c8a23c62c582e679e1..23a5ac94a0f853b56c67338dcfe2ebc6cdcd7155
100644
--- a/lib/asan/asan_interceptors.cc
+++ b/lib/asan/asan_interceptors.cc
@@ -109,6 +109,15 @@ size_t internal_strlen(const char *s) {
return i;
}
+char* internal_strchr(const char *s, int c) {
+ for (size_t i = 0; ; ++i) {
+ if (s[i] == (char)c)
+ return (char*)&s[i];
+ if (s[i] == 0)
+ return NULL;
+ }
+}
+
size_t internal_strnlen(const char *s, size_t maxlen) {
#ifndef __APPLE__
if (REAL(strnlen) != NULL) {
@@ -578,6 +587,7 @@ void InitializeAsanInterceptors() {
// functions for now.
REAL(memcpy) = memcpy;
REAL(memset) = memset;
+ REAL(strchr) = internal_strchr;
#endif
#ifdef __APPLE__
Index: lib/asan/asan_rtl.cc
diff --git a/lib/asan/asan_rtl.cc b/lib/asan/asan_rtl.cc
index
4d3eb6e377078ee2e849f3012e5d439509e965e1..b429a7814790ce345c429072579104e8c0b47fbe
100644
--- a/lib/asan/asan_rtl.cc
+++ b/lib/asan/asan_rtl.cc
@@ -159,6 +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.
+ CHECK(REAL(strchr));
const char *name_end = REAL(strchr)(frame_descr, ' ');
CHECK(name_end);
buf[0] = 0;
More information about the llvm-commits
mailing list