fortify-headers

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

commit 9064a508d5f1ed3514d3e5b4734576e80f7048ae
parent 5494a3f9dce8d3cb1a4f4359084a1ef0ee15333e
Author: jvoisin <julien.voisin@dustri.org>
Date:   Thu,  7 Dec 2023 11:58:47 +0100

Add a global test to ensure that all headers are compiling

Diffstat:
Minclude/stdlib.h | 11++++++++---
Mtests/Makefile | 1+
Atests/test_compile.c | 18++++++++++++++++++
3 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/include/stdlib.h b/include/stdlib.h @@ -23,6 +23,7 @@ __extension__ #include_next <stdlib.h> #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 + #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #if !defined(__cplusplus) && !defined(__clang__) __extension__ @@ -36,6 +37,9 @@ __extension__ extern "C" { #endif + +/* FIXME clang */ +#if !defined(__clang__) #undef malloc #undef realloc #undef calloc @@ -84,8 +88,7 @@ _FORTIFY_FN(reallocarray) void* reallocarray(void* __p, size_t __n, size_t __s) } #endif -/* FIXME clang */ -#if (defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) && !defined(__clang__) +#if (defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) #undef realpath __warning_if(__p == NULL, "'realpath' called with path set to `NULL`; did you invert the arguments?") #if __has_builtin(__builtin_realpath) @@ -118,6 +121,8 @@ _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r) } #endif -#endif +#endif // clang + +#endif // _FORTIFY_SOURCE #endif diff --git a/tests/Makefile b/tests/Makefile @@ -18,6 +18,7 @@ RUNTIME_TARGETS= \ test_bcopy_static_write \ test_bzero_dynamic_write \ test_bzero_static_write \ + test_compile \ test_confstr_dynamic \ test_confstr_static \ test_fgets_dynamic \ diff --git a/tests/test_compile.c b/tests/test_compile.c @@ -0,0 +1,18 @@ +#include "common.h" + +#include <poll.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include <unistd.h> +#include <wchar.h> + +#include <sys/select.h> +#include <sys/socket.h> +#include <sys/stat.h> + +// Check that all headers are compiling. +int main(int argc, char** argv) { + return 0; +}