fortify-headers

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

commit 09b5fc1fd8fefe672fa1bb3ef63cb43e0f5f5476
parent b2c20e6c16278fe556ce4c4ff7d3b146b3a8f009
Author: jvoisin <julien.voisin@dustri.org>
Date:   Sun, 17 Sep 2023 15:12:47 +0200

Add a test for stpcpy

Diffstat:
Mtests/Makefile | 3++-
Atests/test_stpcpy_dynamic_write.c | 16++++++++++++++++
Mtests/test_stpcpy_static_write.c | 2+-
3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile b/tests/Makefile @@ -78,6 +78,7 @@ TARGETS= \ test_stpcpy_overwrite_over \ test_stpcpy_overwrite_under \ test_stpcpy_static_write \ + test_stpcpy_dynamic_write \ test_stpncpy_overwrite_over \ test_stpncpy_overwrite_under \ test_stpncpy_static_write \ @@ -141,7 +142,7 @@ $(TARGETS): %: %.c run: $(TARGETS) $(foreach EXE, $(TARGETS), \ - timeout 1s ./$(EXE) 1 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL" ; \ + timeout 1s ./$(EXE) 1234567890 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL"; \ ) clean: diff --git a/tests/test_stpcpy_dynamic_write.c b/tests/test_stpcpy_dynamic_write.c @@ -0,0 +1,16 @@ +#include "common.h" + +#include <string.h> + +int main(int argc, char** argv) { + char buffer[8] = {0}; + stpcpy(buffer, "1234567"); + puts(buffer); + + CHK_FAIL_START + stpcpy(buffer, argv[1]); + CHK_FAIL_END + + puts(buffer); + return ret; +} diff --git a/tests/test_stpcpy_static_write.c b/tests/test_stpcpy_static_write.c @@ -4,7 +4,7 @@ int main(int argc, char** argv) { char buffer[8] = {0}; - strcpy(buffer, "1234567"); + stpcpy(buffer, "1234567"); puts(buffer); CHK_FAIL_START