fortify-headers

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

commit f8155f0b945c5cfb3600d7c146a5d86870ed09d2
parent 6573631a5e4339a2fc2f86680e36e35e25bf416c
Author: jvoisin <julien.voisin@dustri.org>
Date:   Tue,  8 Oct 2024 03:51:44 +0200

Run various C versions in the CI

Diffstat:
M.github/workflows/testsuite.yaml | 27+++++++++++++++++++++++++++
MREADME.md | 5+++--
Mtests/Makefile | 5++++-
Mtests/common.h | 3+++
Mtests/test_compile.c | 2+-
Mtests/test_fread_overwrite_dynamic.c | 3+--
Mtests/test_fread_overwrite_static.c | 3+--
Mtests/test_fwrite_overwrite_dynamic.c | 3+--
Mtests/test_fwrite_overwrite_static.c | 3+--
Mtests/test_getdomainname_dynamic.c | 5+++--
Mtests/test_getdomainname_static.c | 5+++--
Mtests/test_mbstowcs_dynamic.c | 2+-
Mtests/test_mbstowcs_static.c | 2+-
13 files changed, 50 insertions(+), 18 deletions(-)

diff --git a/.github/workflows/testsuite.yaml b/.github/workflows/testsuite.yaml @@ -78,3 +78,30 @@ jobs: run: | make -C tests clean clang run > ./results.txt grep -zvq 'FAIL' ./results.txt + + c_versions: + runs-on: ubuntu-latest + strategy: + matrix: + version: ["c89", "c99", "c11", "c17"] + steps: + - name: Checking out the code + uses: actions/checkout@v3 + - name: Cache musl toolchain + uses: actions/cache@v3 + id: cache-musl + with: + path: x86_64-linux-musl-native + key: musl + - name: Downloading musl-based toolchain + if: steps.cache-musl.outputs.cache-hit != 'true' + run: wget --quiet https://musl.cc/x86_64-linux-musl-native.tgz + - name: Extracting musl-based toolchain + if: steps.cache-musl.outputs.cache-hit != 'true' + run: tar xzf ./x86_64-linux-musl-native.tgz + - name: Building with clang + shell: bash + run: make CFLAGS=-std=${{ matrix.version }} -C tests clean clang + - name: Building with gcc + shell: bash + run: make CFLAGS=-std=${{ matrix.version }} -C tests clean gcc diff --git a/README.md b/README.md @@ -21,8 +21,9 @@ on Clang. It was initially intended to be used on - Support for out-of-bounds read interfaces, such as send(), write(), fwrite() etc. - No ABI is enforced. All of the fortify check functions are inlined into the resulting binary. -- It has a [comprehensive suite of tests](https://github.com/jvoisin/fortify-headers/tree/master/tests), - running both on Clang and on GCC for every commit, with +- It has a [comprehensive suite of + tests](https://github.com/jvoisin/fortify-headers/tree/master/tests), running + both on Clang and on GCC for every commit, on C89, C99, C11 and C17, with [significant coverage](https://jvoisin.github.io/fortify-headers/) - Defining `FORTIFY_USE_NATIVE_CHK` will make use of compiler-provided builtin `_chk` functions, which might be a bit better in term of diagnostics, diff --git a/tests/Makefile b/tests/Makefile @@ -159,7 +159,10 @@ clang: CFLAGS+=-I../x86_64-linux-musl-native/include/ clang: CFLAGS+=-Ix86_64-linux-musl-native/include/ clang: CFLAGS+=-nostdinc clang: CXX=clang++ -clang: CXXFLAGS=$(CFLAGS) +clang: CXXFLAGS+=-I/usr/include/x86_64-linux-musl +clang: CXXFLAGS+=-I../x86_64-linux-musl-native/include/ +clang: CXXFLAGS+=-Ix86_64-linux-musl-native/include/ +clang: CXXFLAGS+=-nostdinc clang: comptime $(RUNTIME_TARGETS) cpp coverage: CFLAGS += -fprofile-arcs -ftest-coverage diff --git a/tests/common.h b/tests/common.h @@ -15,6 +15,9 @@ License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ +#define _POSIX_C_SOURCE 1 +#define _XOPEN_SOURCE 700 + #include <setjmp.h> #include <unistd.h> #include <signal.h> diff --git a/tests/test_compile.c b/tests/test_compile.c @@ -12,7 +12,7 @@ #include <sys/socket.h> #include <sys/stat.h> -// Check that all headers are compiling. +/* Check that all headers are compiling.*/ int main(int argc, char** argv) { return 0; } diff --git a/tests/test_fread_overwrite_dynamic.c b/tests/test_fread_overwrite_dynamic.c @@ -1,7 +1,6 @@ -#include <assert.h> - #include "common.h" +#include <assert.h> #include <stdio.h> int main(int argc, char** argv) { diff --git a/tests/test_fread_overwrite_static.c b/tests/test_fread_overwrite_static.c @@ -1,7 +1,6 @@ -#include <assert.h> - #include "common.h" +#include <assert.h> #include <stdio.h> int main(int argc, char** argv) { diff --git a/tests/test_fwrite_overwrite_dynamic.c b/tests/test_fwrite_overwrite_dynamic.c @@ -1,7 +1,6 @@ -#include <assert.h> - #include "common.h" +#include <assert.h> #include <stdio.h> int main(int argc, char** argv) { diff --git a/tests/test_fwrite_overwrite_static.c b/tests/test_fwrite_overwrite_static.c @@ -1,7 +1,6 @@ -#include <assert.h> - #include "common.h" +#include <assert.h> #include <stdio.h> int main(int argc, char** argv) { diff --git a/tests/test_getdomainname_dynamic.c b/tests/test_getdomainname_dynamic.c @@ -1,6 +1,7 @@ -#include "common.h" - #define _GNU_SOURCE +#define _DEFAULT_SOURCE + +#include "common.h" #include <unistd.h> diff --git a/tests/test_getdomainname_static.c b/tests/test_getdomainname_static.c @@ -1,6 +1,7 @@ -#include "common.h" - #define _GNU_SOURCE +#define _DEFAULT_SOURCE + +#include "common.h" #include <unistd.h> diff --git a/tests/test_mbstowcs_dynamic.c b/tests/test_mbstowcs_dynamic.c @@ -3,7 +3,7 @@ #include <stdlib.h> int main(int argc, char** argv) { - const char* mbstr = "z\u00df\u6c34\U0001f34c"; // or u8"zß水🍌" + const char* mbstr = "z\u00df\u6c34\U0001f34c"; /* or u8"zß水🍌" */ wchar_t wstr[5]; mbstowcs(wstr, mbstr, 4); diff --git a/tests/test_mbstowcs_static.c b/tests/test_mbstowcs_static.c @@ -3,7 +3,7 @@ #include <stdlib.h> int main(int argc, char** argv) { - const char* mbstr = "z\u00df\u6c34\U0001f34c"; // or u8"zß水🍌" + const char* mbstr = "z\u00df\u6c34\U0001f34c"; /* or u8"zß水🍌" */ wchar_t wstr[5]; mbstowcs(wstr, mbstr, 4);