jvoisin / fortify-headers

Standalone portable header-based implementation of FORTIFY_SOURCE=3
BSD Zero Clause License
15 stars 1 forks source link
c fortify-source libc security

What is it?

This is a standalone implementation of fortify source level 3, providing compile time security checks. It is libc-agnostic and simply overlays the system headers by using the #include_next extension found in GCC, and black magic on Clang. It was initially intended to be used on musl based Linux distributions.

Features

Sample usage

If you want to quickly test it, you can try something like the following:

cat > fgets.c <<EOF
#include <stdio.h>
int
main(void)
{
    char buf[BUFSIZ];
    fgets(buf, sizeof(buf) + 1, stdin);
    return 0;
}
EOF
cc -I<path-to-fortify-include-dir> -D_FORTIFY_SOURCE=3 -O1 fgets.c
./a.out

At this point, the program will safely and loudly crash.

Supported interfaces