fortify-headers

standalone fortify-source implementation
git clone git://git.2f30.org/fortify-headers
Log | Files | Refs | README | LICENSE

commit e16b7ad1168ec48c6e5cf5e5d8e2b2c83815b3ea
parent b1c35c95f1384747b53cb5bdd8d5030068a39602
Author: jvoisin <julien.voisin@dustri.org>
Date:   Wed,  5 Jul 2023 15:41:58 +0200

Add tests for bzero

Diffstat:
Mtests/Makefile | 3+++
Atests/test_bzero_dynamic_write.c | 18++++++++++++++++++
Atests/test_bzero_static_write.c | 18++++++++++++++++++
3 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/tests/Makefile b/tests/Makefile @@ -6,6 +6,9 @@ TARGETS= \ test_bcopy_dynamic_write \ test_bcopy_static_read \ test_bcopy_dynamic_read \ + test_bcopy_dynamic_write \ + test_bzero_dynamic_write \ + test_bzero_static_write \ test_memcpy_static_write \ test_memcpy_dynamic_write \ test_memcpy_static_read \ diff --git a/tests/test_bzero_dynamic_write.c b/tests/test_bzero_dynamic_write.c @@ -0,0 +1,18 @@ +#define _GNU_SOURCE + +#include "common.h" + +#include <strings.h> + +int main(int argc, char** argv) { + char buffer[8] = {0}; + bzero(buffer, sizeof(buffer) - 1); + puts(buffer); + + CHK_FAIL_START + bzero(buffer, argc); + CHK_FAIL_END + + puts(buffer); + return ret; +} diff --git a/tests/test_bzero_static_write.c b/tests/test_bzero_static_write.c @@ -0,0 +1,18 @@ +#define _GNU_SOURCE + +#include "common.h" + +#include <strings.h> + +int main(int argc, char** argv) { + char buffer[8] = {0}; + bzero(buffer, sizeof(buffer) - 1); + puts(buffer); + + CHK_FAIL_START + bzero(buffer, sizeof(buffer) + 1); + CHK_FAIL_END + + puts(buffer); + return ret; +}