fortify-headers

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

README (1887B)


      1 What is it?
      2 ===========
      3 
      4 This is a standalone implementation of fortify source[0].  It provides
      5 compile time buffer checks.  It is libc-agnostic and simply overlays the
      6 system headers by using the #include_next extension found in GCC.  It was
      7 initially intended to be used on musl[1] based Linux distributions[2].
      8 
      9 
     10 Features
     11 ========
     12 
     13 - It is portable, works on *BSD, Linux, Solaris and possibly others.
     14 - It will only trap non-conformant programs.  This means that fortify
     15   level 2 is treated in the same way as level 1.
     16 - Avoids making function calls when undefined behaviour has already been
     17   invoked.  This is handled by using __builtin_trap().
     18 - Support for out-of-bounds read interfaces, such as send(), write(),
     19   fwrite() etc.
     20 - No ABI is enforced.  All of the fortify check functions are inlined
     21   into the resulting binary.
     22 
     23 
     24 Sample usage
     25 ============
     26 
     27 If you want to quickly test it, you can try something like the following:
     28 
     29 cat > fgets.c <<EOF
     30 #include <stdio.h>
     31 int
     32 main(void)
     33 {
     34 	char buf[BUFSIZ];
     35 	fgets(buf, sizeof(buf) + 1, stdin);
     36 	return 0;
     37 }
     38 EOF
     39 cc -I<path-to-fortify-include-dir> -D_FORTIFY_SOURCE=1 -O1 fgets.c
     40 ./a.out
     41 
     42 At this point, the program will safely crash.
     43 
     44 
     45 Supported interfaces
     46 ====================
     47 
     48 FD_CLR
     49 FD_SET
     50 bcopy
     51 bzero
     52 confstr
     53 fgets
     54 fgetws
     55 fread
     56 fwrite
     57 getcwd
     58 getdomainname
     59 getgroups
     60 gethostname
     61 getlogin_r
     62 mbsnrtowcs
     63 mbsrtowcs
     64 mbstowcs
     65 memcpy
     66 memmove
     67 mempcpy
     68 memset
     69 poll
     70 ppoll
     71 pread
     72 read
     73 readlink
     74 readlinkat
     75 realpath
     76 recv
     77 recvfrom
     78 send
     79 sendto
     80 snprintf
     81 sprintf
     82 stpcpy
     83 stpncpy
     84 strcat
     85 strcpy
     86 strlcat
     87 strlcpy
     88 strncat
     89 strncpy
     90 ttyname_r
     91 vsnprintf
     92 vsprintf
     93 wcrtomb
     94 wcscat
     95 wcscpy
     96 wcsncat
     97 wcsncpy
     98 wcsnrtombs
     99 wcsrtombs
    100 wcstombs
    101 wctomb
    102 wmemcpy
    103 wmemmove
    104 wmemset
    105 write
    106 
    107 
    108 [0] http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
    109 [1] http://www.musl-libc.org/
    110 [2] http://git.alpinelinux.org/cgit/aports/commit/?id=067a4f28825478911bb62be3b8da758d9722753e