summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_suppressions.cc3
-rw-r--r--compiler-rt/test/asan/TestCases/Windows/suppressions-crlf.cc19
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
OpenPOWER on IntegriCloud