diff options
| author | Reid Kleckner <rnk@google.com> | 2015-08-26 22:23:50 +0000 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2015-08-26 22:23:50 +0000 |
| commit | ac86c29bd0960f813fd5238c46f16c05909dfb61 (patch) | |
| tree | 87dae1dd22c40747b80aa97be1b31af6b0d4fed2 | |
| parent | 31d38f70eabe8c6138525932963b9cd403149be8 (diff) | |
| download | bcm5719-llvm-ac86c29bd0960f813fd5238c46f16c05909dfb61.tar.gz bcm5719-llvm-ac86c29bd0960f813fd5238c46f16c05909dfb61.zip | |
Handle suppression files ending in CRLF (\r\n)
The gnuwin32 version of 'echo' appears to produce such files, causing a
test failure that only reproduced with gnuwin32.
llvm-svn: 246096
| -rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cc | 3 | ||||
| -rw-r--r-- | compiler-rt/test/asan/TestCases/Windows/suppressions-crlf.cc | 19 |
2 files changed, 21 insertions, 1 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cc b/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cc index 5e0cce13418..2b91fbfe9f8 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cc @@ -112,7 +112,8 @@ void SuppressionContext::Parse(const char *str) { end = line + internal_strlen(line); if (line != end && line[0] != '#') { const char *end2 = end; - while (line != end2 && (end2[-1] == ' ' || end2[-1] == '\t')) + while (line != end2 && + (end2[-1] == ' ' || end2[-1] == '\t' || end2[-1] == '\r')) end2--; int type; for (type = 0; type < suppression_types_num_; type++) { diff --git a/compiler-rt/test/asan/TestCases/Windows/suppressions-crlf.cc b/compiler-rt/test/asan/TestCases/Windows/suppressions-crlf.cc new file mode 100644 index 00000000000..97ca5500096 --- /dev/null +++ b/compiler-rt/test/asan/TestCases/Windows/suppressions-crlf.cc @@ -0,0 +1,19 @@ +// Try a strlen suppression, but force the input file to be DOS format (CRLF). +// RUN: %clangxx_asan -O0 %s -o %t +// RUN: echo "interceptor_name:strlen" > %t.supp +// RUN: unix2dos %t.supp +// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck %s + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int main() { + char *a = (char *)malloc(6); + free(a); + size_t len = strlen(a); // BOOM + fprintf(stderr, "strlen ignored, len = %zu\n", len); +} + +// CHECK-NOT: AddressSanitizer: heap-use-after-free +// CHECK: strlen ignored |

