summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2024-10-10Disable snprintf/sprintf hardening for now2.3.2jvoisin
2024-10-08Run various C versions in the CIjvoisin
2024-10-04Fix usage of strnlenQuentin Rameau
As with previous commit, some strnlen calls where introduced in 22a8094, but not reverted. As strnlen isn't part of C standard, this was breaking C builds.
2024-10-03Use const fd_set for FD_ISSETNatanael Copa
This fixes invalid conversion errors when the fd_set is defined as const. fixes https://github.com/jvoisin/fortify-headers/issues/66
2024-10-03Only install header filesNatanael Copa
Avoid installing *.orig or other files.
2024-09-06Work around a gcc warningjvoisin
It seems that annotating sprintf with `write` makes gcc unhappy, as its analyser is unable to understand that we're checking if `__b != -1` before calling `__orig_snprintf`, so let's comment this annotation for now.
2024-09-02Revert d2594298b89d0fb8989cae3ebc8900e77b6aa478jvoisin
As reported on irc: ``` 17:51 <q> jvoisin, fortify-headers seems to be broken (on Alpine at least) 17:52 <q> Repeating the message from over-there: 17:52 <q> /usr/include/fortify/string.h: In function 'strncat': 17:52 <q> /usr/include/fortify/string.h:297:36: error: implicit declaration of function 'strnlen'; did you mean 'strlen'? [-Wimplicit-function-declaration] 17:52 <q> This is with a simple file that includes string.h and call strncat, built with c99 -O1 f.c ```
2024-07-10Fix access annotation for stpncpy/strncpyjvoisin
The dsize parameter is the length of the dst, not the length of the src. Reported-by: ncopa
2024-07-10Fix access annotations to snprintf/sprintfjvoisin
In the same spirit as the previous commit. Reported-by: ncopa
2024-07-10Fix `access` annotations for vsnprintf/vsprintfjvoisin
This fix the following issue: ``` In file included from exec-cmd.c:9: In function 'vsnprintf', inlined from 'report.constprop' at subcmd-util.h:13:2: /usr/include/fortify/stdio.h:162:16: error: 'msg' may be used uninitialized [-Werror=maybe-uninitialized] 162 | return __orig_vsnprintf(__s, __n, __f, __v); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/fortify/strings.h:23, from /usr/include/string.h:59, from /usr/include/fortify/string.h:23, from /home/ncopa/aports/main/linux-lts/src/linux-6.6/tools/include/linux/string.h:6, from exec-cmd.c:3: /usr/include/fortify/stdio.h: In function 'report.constprop': /usr/include/fortify/stdio.h:152:1: note: in a call to '__orig_vsnprintf' declared with attribute 'access (read_write, 1, 2)' here 152 | _FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n, | ^~~~~~~~~~~ In file included from exec-cmd.c:10: subcmd-util.h:12:14: note: 'msg' declared here 12 | char msg[1024]; | ^~~ cc1: all warnings being treated as errors make[5]: *** [/home/ncopa/aports/main/linux-lts/src/linux-6.6/tools/build/Makefile.build:98: /home/ncopa/aports/main/linux-lts/src/build-virt.x86_64/tools/objtool/libsubcmd/exec-cmd.o] Error 1 make[4]: *** [Makefile:80: /home/ncopa/aports/main/linux-lts/src/build-virt.x86_64/tools/objtool/libsubcmd/libsubcmd-in.o] Error 2 make[3]: *** [Makefile:78: /home/ncopa/aports/main/linux-lts/src/build-virt.x86_64/tools/objtool/libsubcmd/libsubcmd.a] Error 2 make[2]: *** [Makefile:73: objtool] Error 2 make[1]: *** [/home/ncopa/aports/main/linux-lts/src/linux-6.6/Makefile:1362: tools/objtool] Error 2 make: *** [/home/ncopa/aports/main/linux-lts/src/linux-6.6/Makefile:234: __sub-make] Error 2 ``` Reported-by: ncopa
2024-07-10prefix special defines with FORTIFY_psykose
just in case, and because 'PEDANTIC_CHECKS' is a really generic name
2024-07-02Update a bit the readme2.3.1jvoisin
2024-06-21Add a test for C++ compilationjvoisin
2024-06-15Fix some pointer-arithmetic warningsjvoisin
This should fix the second part of #59
2024-06-14Remove `restrict` keywordsjvoisin
- They're not used anywhere else in fortify-headers - It's breaking compilation on C++, because compatibility is hard It was initially reported on https://gitlab.alpinelinux.org/alpine/aports/-/issues/16200
2024-05-26Add vasprintf/asprintf2.3jvoisin
The only hardening being done here is to set the char** parameter to thos functions to NULL in case of an error, to prevent it from being used should people forget to check return values. This is already done on some BSD, as well as in Rocky Linux.
2024-05-20Improve the testsuite reliability wrt. gccjvoisin
2024-04-24Add a testjvoisin
2024-04-24Fix some overlap mismatchjvoisin
This was caught by the following test: ``` int main(void) { char c[32]; memcpy(c, c + 16, 16); } ``` Reported-by: q66
2024-04-24Disable pedantic checks by defaultjvoisin
They can be re-enabled via `PEDANTIC_CHECKS`
2024-03-19Relax our checks for memchr on C11 and above2.2jvoisin
Since C11: > This function behaves as if it reads the bytes sequentially and stops as soon as a matching bytes is found: if the array pointed to by ptr is smaller than count, but the match is found within the array, the behavior is well-defined. Reported-by: q66
2024-03-08Add some NULL-pointers checksjvoisin
See: - https://www.imperialviolet.org/2016/06/26/nonnull.html - https://davidben.net/2024/01/15/empty-slices.html
2024-03-04Add a .gitattributes file to simplify releasesjvoisin
2024-01-13Properly check for builtinsjvoisin
Clang's [documentation](https://clang.llvm.org/docs/LanguageExtensions.html#has-builtin) says: > __has_builtin should not be used to detect support for a builtin macro; use #ifdef instead. So we're now using both, since it's often tedious/non-trivial to find out what is a macro and what is a compiler builtin, across compilers and C versions.
2023-12-28Re-enable previously disabled overlap checksjvoisin
They were previously disabled in 80a83a5
2023-12-28Make the CI fail when the testsuite failsjvoisin
2023-12-28Build with USE_NATIVE_CHK for clang and gccjvoisin
2023-12-27Improve __fh_overlap implementationjvoisin
2023-12-27Don't check for overlapping in strncpy/stpncpy for nowjvoisin
They check overlap across the whole range of the given length, but the given length is not what will actually be copied, rather it's the maximum length (if src is shorter, only length of src will be copied). This triggers false positives and traps where it shouldn't (e.g. in ICU tests). Reported-by: q66
2023-12-18fix typo for __builtin_memcpypsykose
2023-12-16Ditto for strrchrq66
2023-12-16Disable strchr tests since strchr hardening is disabledq66
2023-12-16Also handle SIGTRAP in testsq66
SIGILL is not the only possible trap handler. On non-x86 archs this is not the case for instance.
2023-12-16Bump to 2.12.1q66
2023-12-16Disable str(r)chr hardeningq66
It's UB to subtract null pointers, which these potentially may be. It also makes python test suite fail.
2023-12-15Rename some macros to be more namespace-friendlyq66
2023-12-15Fix missing } for extern "C" when using clangq66
2023-12-15Move wctomb to stdlib.h and disable it for nowq66
2023-12-15Guard some conditional stdio APIs with the right macrosq66
Fixes https://github.com/jvoisin/fortify-headers/issues/34
2023-12-15Do not use static inline for C++ to avoid ODR violationsq66
Fixes https://github.com/jvoisin/fortify-headers/issues/31
2023-12-15Add missing include in select.hq66
2023-12-15Remove superfluous includesJulien Voisin
2023-12-15Remove superfluous includesjvoisin
This should fix #32
2023-12-12Bump to 2.02.0jvoisin
2023-12-10Add gcc 13 to the CIjvoisin
2023-12-08Add a check in the CI to keep the readme up to datejvoisin
2023-12-08Update the readme to point to upstream git repojvoisin
2023-12-07Add qsortjvoisin
2023-12-07Add a global test to ensure that all headers are compilingjvoisin
2023-12-06Work around an erroneous `-Wformat-nonliteral` bug in gccjvoisin
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110834 Reported-by: ksperling-apple