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
This commit is contained in:
Reid Kleckner 2015-08-26 22:23:50 +00:00
parent 31d38f70ea
commit ac86c29bd0
2 changed files with 21 additions and 1 deletions

View File

@ -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++) {

View File

@ -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