Index: test/asan/TestCases/strtol_strict.c =================================================================== --- test/asan/TestCases/strtol_strict.c +++ test/asan/TestCases/strtol_strict.c @@ -41,7 +41,12 @@ assert(r == 37); } +void __attribute__((no_sanitize_address)) underflow_write(char *array) { + array[-1] = '\0'; +} + void test3(char *array, char *endptr) { + underflow_write(array); // Buffer overflow if base is invalid. long r = strtol(array - 1, NULL, -1); assert(r == 0); @@ -93,7 +98,7 @@ // CHECK2: READ of size 4 if (!strcmp(argv[1], "test3")) test3(array, endptr); // CHECK3: {{.*ERROR: AddressSanitizer: heap-buffer-overflow on address}} - // CHECK3: READ of size 5 + // CHECK3: READ of size 1 if (!strcmp(argv[1], "test4")) test4(array, endptr); // CHECK4: {{.*ERROR: AddressSanitizer: heap-buffer-overflow on address}} // CHECK4: READ of size 1 Index: test/asan/TestCases/strtoll_strict.c =================================================================== --- test/asan/TestCases/strtoll_strict.c +++ test/asan/TestCases/strtoll_strict.c @@ -41,7 +41,12 @@ assert(r == 37); } +void __attribute__((no_sanitize_address)) underflow_write(char *array) { + array[-1] = '\0'; +} + void test3(char *array, char *endptr) { + underflow_write(array); // Buffer overflow if base is invalid. long long r = strtoll(array - 1, NULL, -1); assert(r == 0); @@ -93,7 +98,7 @@ // CHECK2: READ of size 4 if (!strcmp(argv[1], "test3")) test3(array, endptr); // CHECK3: {{.*ERROR: AddressSanitizer: heap-buffer-overflow on address}} - // CHECK3: READ of size 5 + // CHECK3: READ of size 1 if (!strcmp(argv[1], "test4")) test4(array, endptr); // CHECK4: {{.*ERROR: AddressSanitizer: heap-buffer-overflow on address}} // CHECK4: READ of size 1