Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
3e6704d
Make use of __builtin_dynamic_object_size
jvoisin Mar 18, 2023
4f1380a
Add a basic testsuite
jvoisin Mar 18, 2023
476fbfc
Add a .gitignore
jvoisin Mar 19, 2023
aceef73
Add tests for memmove
jvoisin Apr 13, 2023
56d760c
Add tests for memset
jvoisin Apr 13, 2023
fa40365
Add tests for strcat and strcpy
jvoisin Apr 13, 2023
b40f6d8
Fix inconsistent time_t version of ppoll
jvoisin May 30, 2023
1ace027
Add a check for overlapping copies in strcpy
jvoisin May 30, 2023
37d8733
Add a test for getcwd
jvoisin May 30, 2023
c4247e4
Add code coverage
jvoisin May 30, 2023
58168af
Add some __attribute__((access…)) annotations
jvoisin May 30, 2023
cb1ce9e
Add tests for strncpy and handle overlapping buffers there
jvoisin Jun 14, 2023
af7480d
Add tests for stpcpy
jvoisin Jun 22, 2023
532f4bf
Add tests for stcncpy
jvoisin Jun 22, 2023
b714dbd
Add a test for strncat
jvoisin Jun 22, 2023
79447cb
Add tests for mempcpy
jvoisin Jun 22, 2023
28d61f4
Add a test for `poll`
jvoisin Jun 22, 2023
dad7183
Add a test for ppoll
jvoisin Jun 22, 2023
44a71e3
Add an annotation for fgets
jvoisin Jun 22, 2023
5827cef
Add a test for fgets
jvoisin Jun 22, 2023
adae76a
avoid __extension__ with clang
Nov 1, 2022
fe14962
add initial clang support
Oct 25, 2022
8848bca
Fix clang support
jvoisin Jun 25, 2023
87cdb23
Run clang and gcc in the CI
jvoisin Jun 25, 2023
3ff7b4d
Fix the coverage on github pages
jvoisin Jun 25, 2023
22bb8f4
Add more access-annotations
jvoisin Jun 27, 2023
d5ba737
Don't download musl-cc for clang in the CI
jvoisin Jul 4, 2023
e0f804d
Run several clang versions in the CI
jvoisin Jul 4, 2023
a8f6f7a
Cache musl-toolchain download
jvoisin Jul 4, 2023
b1c35c9
Add tests for bcopy
jvoisin Jul 5, 2023
e16b7ad
Add tests for bzero
jvoisin Jul 5, 2023
6219903
Add access annotations to sys/socket.h
jvoisin Jul 5, 2023
e892e11
Add tests for memcpy overflow/underflow
jvoisin Jul 8, 2023
f774a49
Add access annotations to unistd.h
jvoisin Jul 8, 2023
6939c9e
Fix a couple of warnings
jvoisin Jul 9, 2023
33acec5
Add tests for unistd.h
jvoisin Jul 9, 2023
f9f83da
Add tests for stdio.h
jvoisin Jul 9, 2023
a37c769
Improve a bit `size_t*size_t` overflow checks
jvoisin Jul 9, 2023
2cef5af
Add an __access__ annotation to wchar.h
jvoisin Jul 9, 2023
190e386
Move a misplaced #endif
jvoisin Jul 9, 2023
b333df2
Add some `format` annotations
jvoisin Jul 9, 2023
e7c10a1
Add some malloc annotations
jvoisin Jul 9, 2023
106785b
Clean up a bit the macro hell
jvoisin Jul 10, 2023
874c40f
Add tests for sys/socket.h
jvoisin Jul 10, 2023
875b469
Add tests for sys/socket
jvoisin Jul 10, 2023
906b7f6
Add some dynamic tests for sys/socket.h
jvoisin Jul 10, 2023
552cf2f
Add some dynamic tests for unistd.h
jvoisin Jul 10, 2023
759cb46
Sort build targets in the tests' Makefile
jvoisin Jul 10, 2023
8b61293
Add more dynamic tests
jvoisin Jul 10, 2023
9aa4490
Make use of the alloc_size attribute
jvoisin Jul 18, 2023
5e0ea3e
Add hardening for memchr and memrchr
jvoisin Aug 3, 2023
fea08b7
Remove memrchr hardening for now
jvoisin Aug 20, 2023
f0305fb
Add two tests for memchr
jvoisin Aug 20, 2023
e441ae8
Add hardening for strchr
jvoisin Aug 20, 2023
e182dd0
Add hardening for strrchr
jvoisin Aug 20, 2023
70bbb62
Refresh a bit the README
jvoisin Aug 20, 2023
c17d476
Fix some sizeof-related typoes in the testsuite
jvoisin Aug 20, 2023
bc50ed6
Fix clang build
jvoisin Aug 20, 2023
c29287d
Make use of pass_dynamic_object_size when available
jvoisin Aug 20, 2023
d6afda7
Use pass_dynamic_object_size only for FORTIFY_SOURCE > 2
jvoisin Aug 20, 2023
bfbaa57
Make use of __diagnose_as_builtin
jvoisin Aug 20, 2023
737b520
Specify "shell: bash" in github actions
jvoisin Aug 20, 2023
8802b23
Add two __format annotations
jvoisin Aug 20, 2023
d6ad45a
Add more __access annotations in stdio.h
jvoisin Aug 20, 2023
6265210
Run the testsuite on multiple gcc versions
jvoisin Aug 20, 2023
0f19089
Cache the musl toolchain in the coverage step in the CI
jvoisin Aug 20, 2023
a9abb9f
Split build and run
jvoisin Aug 20, 2023
8152712
Remove the testsuite from the coverage data
jvoisin Aug 20, 2023
d9feee0
Add tests for fgetws and mbsrtowcs
jvoisin Aug 20, 2023
d343ba0
Add coverity analysis
jvoisin Aug 20, 2023
254471b
Remove some todo in __bmo's implementation
jvoisin Aug 21, 2023
e8b8e4f
Make use of __diagnose_if
jvoisin Aug 21, 2023
5a387ce
Improve the .gitignore file wrt. tests
jvoisin Aug 21, 2023
cceaaa8
Harden umask
jvoisin Aug 21, 2023
bc0c8a5
Add tests for mbstowcs
jvoisin Aug 21, 2023
9231e09
Add tests for wmemset
jvoisin Aug 21, 2023
acfa9f6
Add hardening for pwrite
jvoisin Aug 22, 2023
e93e932
Increase portability
jvoisin Aug 22, 2023
f3ff539
Show the failing file name in the testsuite
jvoisin Aug 22, 2023
2c610a2
Clean up some includes
jvoisin Aug 22, 2023
fd36113
Add two tests for wmemmove
jvoisin Aug 26, 2023
f12211f
Fix the coverity run
jvoisin Aug 28, 2023
1403ff9
Add tests for wmemcpy
jvoisin Sep 3, 2023
3df1d6a
Install wget for the coverity workflow
jvoisin Sep 4, 2023
07da675
Add a bunch of wchar_t tests
jvoisin Sep 11, 2023
5ce4b94
Add the warn_unused_result attribute to alloc-related functions
jvoisin Sep 11, 2023
f3c9815
Add a warning if realpath is called with path set to NULL
jvoisin Sep 11, 2023
beb2422
Add a warning for _FORTIFY_SOURCE>3
jvoisin Sep 11, 2023
b9bd940
Fix a warning
jvoisin Sep 11, 2023
b2c20e6
Factorize overlap checks into a macro
jvoisin Sep 11, 2023
09b5fc1
Add a test for stpcpy
jvoisin Sep 17, 2023
1122a7b
Add dynamic tests for strcpy and strncat
jvoisin Sep 17, 2023
267d5db
Add more dynamic tests
jvoisin Sep 17, 2023
62c2658
Fix compilation under clang for bsd-specific functions
jvoisin Sep 17, 2023
d2ab22e
Make use of the buffers in the wide-chars tests
jvoisin Sep 17, 2023
d259429
Replace a strlen+condition with strnlen
jvoisin Sep 20, 2023
fd4332d
Add tests for compile-time errors
jvoisin Sep 20, 2023
46add4c
Add clang 15 to the CI
jvoisin Sep 20, 2023
8c2352b
Properly enable diagnose_as_builtin attribute
jvoisin Sep 21, 2023
75b95fa
Add more __diagnose_as_builtin annotations
jvoisin Sep 22, 2023
2ccfced
Add an option to make use of compiler-provided _chk builtins
jvoisin Sep 27, 2023
81ef1fd
Add support for more builtin compiler provided _chk variants
jvoisin Sep 27, 2023
3067c28
Add `printf` hardening
jvoisin Sep 27, 2023
4988174
Make use of the native _chk variants for real
jvoisin Sep 29, 2023
a274527
Add `strlen`
jvoisin Sep 29, 2023
160298c
Fix a typo
jvoisin Sep 30, 2023
76fef96
Add `vprintf`
jvoisin Sep 30, 2023
6a801d8
Add `fprintf`
jvoisin Oct 1, 2023
32b21b7
Add vfprintf`
jvoisin Oct 1, 2023
8439dc0
Add a check about redefined macros
jvoisin Oct 16, 2023
cfdcaf7
Add support for FD_ISSET
jvoisin Nov 1, 2023
52ec484
Add hardening for select()
jvoisin Nov 16, 2023
7e6100d
Add hardening for select()
jvoisin Nov 16, 2023
d3e8c46
Update the README
jvoisin Dec 5, 2023
5494a3f
Work around an erroneous `-Wformat-nonliteral` bug in gcc
jvoisin Dec 6, 2023
9064a50
Add a global test to ensure that all headers are compiling
jvoisin Dec 7, 2023
b5d5ceb
Add qsort
jvoisin Dec 6, 2023
5822607
Update the readme to point to upstream git repo
jvoisin Dec 8, 2023
36d7b91
Add a check in the CI to keep the readme up to date
jvoisin Dec 8, 2023
4be9974
Add gcc 13 to the CI
jvoisin Dec 10, 2023
8342bc5
Bump to 2.0
jvoisin Dec 12, 2023
57a3e9c
Remove superfluous includes
jvoisin Dec 15, 2023
e83bd59
Remove superfluous includes
jvoisin Dec 15, 2023
3e00ac3
Add missing include in select.h
q66 Dec 15, 2023
c607773
Do not use static inline for C++ to avoid ODR violations
q66 Dec 15, 2023
8d090c8
Guard some conditional stdio APIs with the right macros
q66 Dec 15, 2023
ca2df48
Move wctomb to stdlib.h and disable it for now
q66 Dec 15, 2023
95441d2
Fix missing } for extern "C" when using clang
q66 Dec 15, 2023
a018052
Rename some macros to be more namespace-friendly
q66 Dec 15, 2023
021e25b
Disable str(r)chr hardening
q66 Dec 15, 2023
8e15a75
Bump to 2.1
q66 Dec 16, 2023
ca2ede3
Also handle SIGTRAP in tests
q66 Dec 16, 2023
9d7f007
Disable strchr tests since strchr hardening is disabled
q66 Dec 16, 2023
c59aa9a
Ditto for strrchr
q66 Dec 16, 2023
01dc0e3
fix typo for __builtin_memcpy
nekopsykose Dec 18, 2023
80a83a5
Don't check for overlapping in strncpy/stpncpy for now
jvoisin Dec 27, 2023
8513fdd
Improve __fh_overlap implementation
jvoisin Dec 27, 2023
bcf82d5
Build with USE_NATIVE_CHK for clang and gcc
jvoisin Dec 28, 2023
f3c0bfd
Make the CI fail when the testsuite fails
jvoisin Dec 28, 2023
22a8094
Re-enable previously disabled overlap checks
jvoisin Dec 27, 2023
1a84314
Properly check for builtins
jvoisin Jan 13, 2024
2f60f25
Add a .gitattributes file to simplify releases
jvoisin Mar 4, 2024
140cffb
Add some NULL-pointers checks
jvoisin Mar 8, 2024
8ed72e7
Relax our checks for memchr on C11 and above
jvoisin Mar 19, 2024
265fa03
Disable pedantic checks by default
jvoisin Apr 24, 2024
a817e15
Fix some overlap mismatch
jvoisin Apr 24, 2024
3375426
Add a test
jvoisin Apr 24, 2024
92c611a
Improve the testsuite reliability wrt. gcc
jvoisin May 20, 2024
1becad4
Add vasprintf/asprintf
jvoisin May 20, 2024
6939e33
Remove `restrict` keywords
jvoisin Jun 14, 2024
520e7e4
Fix some pointer-arithmetic warnings
jvoisin Jun 14, 2024
8f8e5c1
Add a test for C++ compilation
jvoisin Jun 21, 2024
936d55d
Update a bit the readme
jvoisin Jul 2, 2024
459d202
prefix special defines with FORTIFY_
nekopsykose Jul 10, 2024
6f54232
Fix `access` annotations for vsnprintf/vsprintf
jvoisin Jul 10, 2024
9014b02
Fix access annotations to snprintf/sprintf
jvoisin Jul 10, 2024
c4d9299
Fix access annotation for stpncpy/strncpy
jvoisin Jul 10, 2024
114b563
Revert d2594298b89d0fb8989cae3ebc8900e77b6aa478
jvoisin Sep 2, 2024
f2e7f24
Work around a gcc warning
jvoisin Sep 6, 2024
63f1b1c
Only install header files
ncopa Oct 3, 2024
60202fb
Use const fd_set for FD_ISSET
ncopa Oct 3, 2024
6573631
Fix usage of strnlen
Oct 2, 2024
f8155f0
Run various C versions in the CI
jvoisin Oct 8, 2024
d03a9d4
Fix native check in testsuite
ncopa Oct 3, 2024
b7a5358
Don't hardcode gcc path in testsuite makefile
ncopa Oct 3, 2024
849de95
Build testdir binaries in subdirectory
ncopa Oct 3, 2024
9a8cbb1
Add FORTIFY_CFLAGS to testsuite
ncopa Oct 3, 2024
b0809da
Move system/arch dependent includes to env var SYS_INCLUDES
ncopa Oct 3, 2024
91576a3
Refactor testsuite
ncopa Oct 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.gitattributes export-ignore
.github/** export-ignore
.gitignore export-ignore
53 changes: 53 additions & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Deploy static content to Pages

on:
push:
branches: ["master"]

workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: true

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
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: Installing lcov
run: sudo apt install lcov
- name: Running the testsuite
run: make -C tests clean coverage run
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Upload entire repository
path: './tests/coverage/'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2

51 changes: 51 additions & 0 deletions .github/workflows/coverity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Coverity scan
on:
schedule:
- cron: '0 18 * * 1' # Weekly at 18:00 UTC on Mondays

jobs:
latest:
runs-on: ubuntu-latest
container: debian:stable
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
apt update
DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends curl ca-certificates make wget
- 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: Download Coverity Build Tool
run: |
curl https://scan.coverity.com/download/linux64 --form token=$TOKEN --form project=jvoisin/fortify-headers -o cov-analysis-linux64.tar.gz
mkdir cov-analysis-linux64
tar xzf cov-analysis-linux64.tar.gz --strip-components=1 -C cov-analysis-linux64
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
- name: Build with cov-build
run: ./cov-analysis-linux64/bin/cov-build --dir cov-int make -C tests gcc
- name: Submit the result to Coverity Scan
run: |
tar czf fortify-headers.tgz cov-int
curl \
--form project=jvoisin/fortify-headers \
--form token=$TOKEN \
--form file=@fortify-headers.tgz \
--form version=master \
--form email=julien.voisin+coverity@dustri.org \
--form description=master \
https://scan.coverity.com/builds?project=jvoisin/fortify-headers
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
18 changes: 18 additions & 0 deletions .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Check that the README is up to date

on:
pull_request:
push:

jobs:
latest:
runs-on: ubuntu-latest
steps:
- name: Checking out the code
uses: actions/checkout@v3
- run: |
for function in $(find include/ -type f -exec sed -n 's/^_FORTIFY_FN(\([^)]\+\)).*/\1/p' '{}' ';' | sort | uniq)
do
grep "\`$function\`" README.md || (echo "Please add \`$function\` to the README.md file." && exit 1)
done

113 changes: 113 additions & 0 deletions .github/workflows/testsuite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Test suite
on:
pull_request:
push:
schedule:
- cron: '0 16 * * 5'

jobs:
gcc:
runs-on: ubuntu-latest
strategy:
matrix:
version: [9, 10, 11, 12, 13]
use_native_chk: [true, false]
env:
CC: ../x86_64-linux-musl-native/bin/gcc
SYS_INCLUDES: -I/usr/include/x86_64-linux-musl -I../x86_64-linux-musl-native/include/ -Ix86_64-linux-musl-native/include/
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: Setting up gcc version
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install -y --no-install-recommends gcc-${{ matrix.version }} g++-${{ matrix.version }}
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${{ matrix.version }} 100
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ matrix.version }} 100
- name: Build with native chk
if: ${{ matrix.use_native_chk == true }}
run: make TARGET_DIR=out.gcc.native_chk CFLAGS=-DFORTIFY_USE_NATIVE_CHK -C tests
- name: Build without native chk, and run the testsuite
if: ${{ matrix.use_native_chk == false }}
shell: bash
run: |
make -C tests check > ./results.txt
grep -zvq 'FAIL' ./results.txt

clang:
runs-on: ubuntu-latest
env:
SYS_INCLUDES: -I/usr/include/x86_64-linux-musl -I../x86_64-linux-musl-native/include/ -Ix86_64-linux-musl-native/include/
CC: clang
strategy:
matrix:
version: [13, 14, 15]
use_native_chk: [true, false]
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: Setting up clang version
run: |
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${{ matrix.version }} 100
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{ matrix.version }} 100
- name: Build with native chk
if: ${{ matrix.use_native_chk == true }}
run: make CFLAGS=-DFORTIFY_USE_NATIVE_CHK SYS_INCLUDES="$SYS_INCLUDES" CC=clang -C tests clang
- name: Building and running without native chk
if: ${{ matrix.use_native_chk == false }}
shell: bash
run: |
make SYS_INCLUDES="$SYS_INCLUDES" CC=clang TARGET_DIR=out.clang -C tests check > ./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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
x86_64-linux-musl-native
x86_64-linux-musl-native.tgz
tests/*
!tests/*.c
!tests/Makefile
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
VERSION = 1.1
VERSION = 2.1
PREFIX = /usr/local

install:
mkdir -p $(DESTDIR)$(PREFIX)/include/fortify
cp -R include/* $(DESTDIR)$(PREFIX)/include/fortify
install -D -t $(DESTDIR)$(PREFIX)/include/fortify \
include/*.h
install -D -t $(DESTDIR)$(PREFIX)/include/fortify/sys \
include/sys/*.h

uninstall:
rm -rf $(DESTDIR)$(PREFIX)/include/fortify
Expand All @@ -15,6 +17,8 @@ dist: clean
gzip fortify-headers-$(VERSION).tar
rm -rf fortify-headers-$(VERSION)

check:
$(MAKE) -C tests check
clean:
rm -f fortify-headers-$(VERSION).tar.gz

Expand Down
110 changes: 0 additions & 110 deletions README

This file was deleted.

Loading