diff options
| author | jvoisin | 2023-08-22 19:16:49 +0200 |
|---|---|---|
| committer | jvoisin | 2023-08-22 19:16:49 +0200 |
| commit | acfa9f6ce8295b2493b4e21b73463b93ef3c4333 (patch) | |
| tree | 0b4ad45ed42caf5bf407f05ec75deb9ccba46ff5 /tests | |
| parent | 9231e0905829f1c33abe07bed9be35298c9bdcf5 (diff) | |
Add hardening for pwrite
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Makefile | 2 | ||||
| -rw-r--r-- | tests/test_pwrite_dynamic.c | 14 | ||||
| -rw-r--r-- | tests/test_pwrite_static.c | 14 |
3 files changed, 30 insertions, 0 deletions
diff --git a/tests/Makefile b/tests/Makefile index 1f92b36..1c73c7e 100644 --- a/tests/Makefile +++ b/tests/Makefile | |||
| @@ -63,6 +63,8 @@ TARGETS= \ | |||
| 63 | test_ppoll_static \ | 63 | test_ppoll_static \ |
| 64 | test_pread_dynamic \ | 64 | test_pread_dynamic \ |
| 65 | test_pread_static \ | 65 | test_pread_static \ |
| 66 | test_pwrite_dynamic \ | ||
| 67 | test_pwrite_static \ | ||
| 66 | test_read_dynamic \ | 68 | test_read_dynamic \ |
| 67 | test_read_static \ | 69 | test_read_static \ |
| 68 | test_readlink_dynamic \ | 70 | test_readlink_dynamic \ |
diff --git a/tests/test_pwrite_dynamic.c b/tests/test_pwrite_dynamic.c new file mode 100644 index 0000000..8e132ed --- /dev/null +++ b/tests/test_pwrite_dynamic.c | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | #include "common.h" | ||
| 2 | |||
| 3 | #include <unistd.h> | ||
| 4 | |||
| 5 | int main(int argc, char** argv) { | ||
| 6 | char buffer[8] = {0}; | ||
| 7 | |||
| 8 | CHK_FAIL_START | ||
| 9 | pwrite(0, buffer, argc, 0); | ||
| 10 | CHK_FAIL_END | ||
| 11 | |||
| 12 | puts(buffer); | ||
| 13 | return ret; | ||
| 14 | } | ||
diff --git a/tests/test_pwrite_static.c b/tests/test_pwrite_static.c new file mode 100644 index 0000000..6815fd4 --- /dev/null +++ b/tests/test_pwrite_static.c | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | #include "common.h" | ||
| 2 | |||
| 3 | #include <unistd.h> | ||
| 4 | |||
| 5 | int main(int argc, char** argv) { | ||
| 6 | char buffer[12] = {0}; | ||
| 7 | |||
| 8 | CHK_FAIL_START | ||
| 9 | pwrite(0, buffer, 14, 0); | ||
| 10 | CHK_FAIL_END | ||
| 11 | |||
| 12 | puts(buffer); | ||
| 13 | return ret; | ||
| 14 | } | ||
