[PATCH] PR23230 Fix asan strtol_strict/strtoll_strict tests
Maria Guseva
m.guseva at samsung.com
Wed May 27 09:45:03 PDT 2015
Hi kcc, samsonov, glider,
This is a patch to fix the bug reported here: https://llvm.org/bugs/show_bug.cgi?id=23230
http://reviews.llvm.org/D10063
Files:
test/asan/TestCases/strtol_strict.c
test/asan/TestCases/strtoll_strict.c
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
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10063.26607.patch
Type: text/x-patch
Size: 1819 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150527/f2cc9461/attachment.bin>
More information about the llvm-commits
mailing list