commit 1122a7b8d9ab1c6ea030fac11495fc75aae07d42
parent 09b5fc1fd8fefe672fa1bb3ef63cb43e0f5f5476
Author: jvoisin <julien.voisin@dustri.org>
Date: Sun, 17 Sep 2023 15:48:42 +0200
Add dynamic tests for strcpy and strncat
Diffstat:
3 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/tests/Makefile b/tests/Makefile
@@ -88,7 +88,9 @@ TARGETS= \
test_strcpy_overwrite_over \
test_strcpy_overwrite_under \
test_strcpy_static_write \
+ test_strcpy_dynamic_write \
test_strncat_static_write \
+ test_strncat_dynamic_write \
test_strncpy_overwrite_over \
test_strncpy_overwrite_under \
test_strncpy_static_write \
diff --git a/tests/test_strcpy_dynamic_write.c b/tests/test_strcpy_dynamic_write.c
@@ -0,0 +1,16 @@
+#include "common.h"
+
+#include <string.h>
+
+int main(int argc, char** argv) {
+ char buffer[8] = {0};
+ strcpy(buffer, "1234567");
+ puts(buffer);
+
+ CHK_FAIL_START
+ strcpy(buffer, argv[1]);
+ CHK_FAIL_END
+
+ puts(buffer);
+ return ret;
+}
diff --git a/tests/test_strncat_dynamic_write.c b/tests/test_strncat_dynamic_write.c
@@ -0,0 +1,16 @@
+#include "common.h"
+
+#include <string.h>
+
+int main(int argc, char** argv) {
+ char buffer[8] = {0};
+ strncat(buffer, "1234567", 5);
+ puts(buffer);
+
+ CHK_FAIL_START
+ strncat(buffer, argv[1], argc);
+ CHK_FAIL_END
+
+ puts(buffer);
+ return ret;
+}