forked from OSchip/llvm-project
Revert "SIGSEGV in Sanitizer INTERCEPTOR of strstr function."
Breaks Asan on Fuchsia's and ubsan with gcc.
This reverts commit 685c94c6cb
.
This commit is contained in:
parent
50b5b367c1
commit
6396a44361
|
@ -575,12 +575,10 @@ INTERCEPTOR(int, strncasecmp, const char *s1, const char *s2, SIZE_T size) {
|
|||
#if SANITIZER_INTERCEPT_STRSTR || SANITIZER_INTERCEPT_STRCASESTR
|
||||
static inline void StrstrCheck(void *ctx, char *r, const char *s1,
|
||||
const char *s2) {
|
||||
uptr len2 = internal_strlen(s2);
|
||||
COMMON_INTERCEPTOR_READ_RANGE(ctx, s2, len2 + 1);
|
||||
if (len2 == 0 && !common_flags()->strict_string_checks)
|
||||
return;
|
||||
uptr len1 = internal_strlen(s1);
|
||||
COMMON_INTERCEPTOR_READ_STRING(ctx, s1, r ? r - s1 + len2 : len1 + 1);
|
||||
uptr len1 = internal_strlen(s1);
|
||||
uptr len2 = internal_strlen(s2);
|
||||
COMMON_INTERCEPTOR_READ_STRING(ctx, s1, r ? r - s1 + len2 : len1 + 1);
|
||||
COMMON_INTERCEPTOR_READ_RANGE(ctx, s2, len2 + 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -217,10 +217,8 @@ uptr internal_strnlen(const char *s, uptr maxlen) {
|
|||
|
||||
char *internal_strstr(const char *haystack, const char *needle) {
|
||||
// This is O(N^2), but we are not using it in hot places.
|
||||
uptr len2 = internal_strlen(needle);
|
||||
if (len2 == 0)
|
||||
return const_cast<char *>(haystack);
|
||||
uptr len1 = internal_strlen(haystack);
|
||||
uptr len2 = internal_strlen(needle);
|
||||
if (len1 < len2) return nullptr;
|
||||
for (uptr pos = 0; pos <= len1 - len2; pos++) {
|
||||
if (internal_memcmp(haystack + pos, needle, len2) == 0)
|
||||
|
|
|
@ -8,9 +8,5 @@ int main(int argc, char **argv) {
|
|||
char s2[] = "b";
|
||||
r = strstr(s1, s2);
|
||||
assert(r == s1 + 1);
|
||||
char *s3 = NULL;
|
||||
char *s4 = "";
|
||||
char *p = strstr(s3, s4);
|
||||
assert(p == NULL);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue