fortify-headers

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

commit 5827cef597d2b9b87b950c9b50023d11b1363c04
parent 44a71e36ed37781fa850662f479734cce1c354ce
Author: jvoisin <julien.voisin@dustri.org>
Date:   Fri, 23 Jun 2023 00:28:01 +0200

Add a test for fgets

Diffstat:
Mtests/Makefile | 4+++-
Atests/test_fgets.c | 15+++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/tests/Makefile b/tests/Makefile @@ -2,7 +2,9 @@ CC=../x86_64-linux-musl-native/bin/gcc GCOV=../x86_64-linux-musl-native/bin/gcov CFLAGS=-I../include/ -D_FORTIFY_SOURCE=3 -static -O2 -TARGETS=test_memcpy_static_write \ +TARGETS= \ + test_fgets \ + test_memcpy_static_write \ test_memcpy_dynamic_write \ test_memcpy_static_read \ test_memcpy_dynamic_read \ diff --git a/tests/test_fgets.c b/tests/test_fgets.c @@ -0,0 +1,15 @@ +#include "common.h" + +#define _GNU_SOURCE +#include <poll.h> + +int main(int argc, char** argv) { + char buffer[12] = {0}; + + CHK_FAIL_START + fgets(buffer, 14, NULL); + CHK_FAIL_END + + puts(buffer); + return ret; +}