From a2745278eb03d63f4df8da4367f27ec8cab7deb9 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 30 Sep 2023 00:15:26 +0200 Subject: Add `strlen` --- tests/Makefile | 1 + tests/test_strlen_static_read.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/test_strlen_static_read.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 81593cf..c862c52 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -87,6 +87,7 @@ RUNTIME_TARGETS= \ test_stpncpy_overwrite_over \ test_stpncpy_overwrite_under \ test_stpncpy_static_write \ + test_strlen_static_read \ test_strcat_static_write \ test_strchr_dynamic_read \ test_strchr_static_read \ diff --git a/tests/test_strlen_static_read.c b/tests/test_strlen_static_read.c new file mode 100644 index 0000000..b1f928d --- /dev/null +++ b/tests/test_strlen_static_read.c @@ -0,0 +1,22 @@ +#define _GNU_SOURCE +#define _BSD_SOURCE + +#include "common.h" + +#include + +int main(int argc, char** argv) { + char* canary1 = "ABCDEFGHIJKLMNOPQ"; + char buf[] = {'a', 'b', 'c', 'd', '\0'}; + char* canary2 = "ABCDEF"; + strlen(buf); + puts(buf); + buf[4] = 'e'; + + CHK_FAIL_START + strlen(buf); + CHK_FAIL_END + + puts(argv[1]); + return ret; +} -- cgit v1.3