diff options
| author | jvoisin | 2023-08-20 18:09:14 +0200 |
|---|---|---|
| committer | jvoisin | 2023-08-20 18:09:14 +0200 |
| commit | e441ae8c30b35ad7602ab428753afb4a335b34bf (patch) | |
| tree | 4c993f8817f20058a595c255711c26ef6a108795 /tests/test_strchr_dynamic_read.c | |
| parent | f0305fb85796cc4dcc537123d6b9b3152cf0c4be (diff) | |
Add hardening for strchr
Diffstat (limited to 'tests/test_strchr_dynamic_read.c')
| -rw-r--r-- | tests/test_strchr_dynamic_read.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_strchr_dynamic_read.c b/tests/test_strchr_dynamic_read.c new file mode 100644 index 0000000..fdd69df --- /dev/null +++ b/tests/test_strchr_dynamic_read.c | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | #include "common.h" | ||
| 2 | |||
| 3 | #include <string.h> | ||
| 4 | |||
| 5 | int main(int argc, char** argv) { | ||
| 6 | char buffer[] = {'1', '2', '3', '4', '5'}; | ||
| 7 | const char* padding = "ABCDEFGHIJKLMN"; | ||
| 8 | strchr(buffer, (int)'4'); | ||
| 9 | puts(buffer); | ||
| 10 | |||
| 11 | CHK_FAIL_START | ||
| 12 | strchr(buffer, (int)'A'); | ||
| 13 | CHK_FAIL_END | ||
| 14 | |||
| 15 | puts(buffer); | ||
| 16 | return ret; | ||
| 17 | } | ||
