diff options
| author | jvoisin | 2023-06-14 14:59:11 +0200 |
|---|---|---|
| committer | jvoisin | 2023-06-14 14:59:11 +0200 |
| commit | cb1ce9e1815a492de0f13c2b046b8472024b9f6d (patch) | |
| tree | 77b3a8268151533ad4dc7acec73d25d2144cd991 /tests/test_strncpy_overwrite_over.c | |
| parent | 58168afc8b2328c24137820c5fbe7c9775901944 (diff) | |
Add tests for strncpy and handle overlapping buffers there
Diffstat (limited to 'tests/test_strncpy_overwrite_over.c')
| -rw-r--r-- | tests/test_strncpy_overwrite_over.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_strncpy_overwrite_over.c b/tests/test_strncpy_overwrite_over.c new file mode 100644 index 0000000..d584bcc --- /dev/null +++ b/tests/test_strncpy_overwrite_over.c | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | #include "common.h" | ||
| 2 | |||
| 3 | #include <string.h> | ||
| 4 | |||
| 5 | int main(int argc, char** argv) { | ||
| 6 | char buffer[9] = {'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', '\0'}; | ||
| 7 | puts(buffer); | ||
| 8 | |||
| 9 | CHK_FAIL_START | ||
| 10 | strncpy(buffer+1, buffer, 5); | ||
| 11 | CHK_FAIL_END | ||
| 12 | |||
| 13 | puts(buffer); | ||
| 14 | return ret; | ||
| 15 | } | ||
