fortify-headers

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

commit d12254166a55d17932ea4143fbd50fb52539ff8b
parent c4abf4497ba24d716250af4186757b5c5952f54e
Author: sin <sin@2f30.org>
Date:   Fri, 13 Mar 2015 23:09:15 +0000

Restore C++ support

Diffstat:
MREADME | 2--
Minclude/poll.h | 7++++++-
Minclude/stdio.h | 7++++++-
Minclude/stdlib.h | 6+++++-
Minclude/string.h | 7++++++-
Minclude/strings.h | 6+++++-
Minclude/sys/select.h | 6+++++-
Minclude/sys/socket.h | 7++++++-
Minclude/unistd.h | 7++++++-
Minclude/wchar.h | 7++++++-
10 files changed, 51 insertions(+), 11 deletions(-)

diff --git a/README b/README @@ -6,8 +6,6 @@ and simply overlays the system headers by using the #include_next extension foun in GCC and clang. It was initially intended to be used on musl[1] based Linux distributions. -NOTE: It does *not* support C++. For C++ programs, the fortify headers -will essentially be a no-op. Features ======== diff --git a/include/poll.h b/include/poll.h @@ -5,7 +5,10 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#ifndef __cplusplus +#ifdef __cplusplus +extern "C" { +#endif + #undef poll extern int __poll_orig(struct pollfd *, nfds_t, int) @@ -35,6 +38,8 @@ int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, const } #endif +#ifdef __cplusplus +} #endif #endif diff --git a/include/stdio.h b/include/stdio.h @@ -5,7 +5,10 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#ifndef __cplusplus +#ifdef __cplusplus +extern "C" { +#endif + #undef fgets #undef fread #undef fwrite @@ -114,6 +117,8 @@ int sprintf(char *s, const char *fmt, ...) return r; } +#ifdef __cplusplus +} #endif #endif diff --git a/include/stdlib.h b/include/stdlib.h @@ -9,7 +9,9 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#ifndef __cplusplus +#ifdef __cplusplus +extern "C" { +#endif #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #undef realpath @@ -33,6 +35,8 @@ char *realpath(const char *path, char *resolved) } #endif +#ifdef __cplusplus +} #endif #endif diff --git a/include/string.h b/include/string.h @@ -5,7 +5,10 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#ifndef __cplusplus +#ifdef __cplusplus +extern "C" { +#endif + #undef memcpy #undef memmove #undef memset @@ -181,6 +184,8 @@ size_t strlcpy(char *dest, const char *src, size_t n) } #endif +#ifdef __cplusplus +} #endif #endif diff --git a/include/strings.h b/include/strings.h @@ -5,7 +5,9 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#ifndef __cplusplus +#ifdef __cplusplus +extern "C" { +#endif #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \ || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \ @@ -37,6 +39,8 @@ void bzero(void *src, size_t n) } #endif +#ifdef __cplusplus +} #endif #endif diff --git a/include/sys/select.h b/include/sys/select.h @@ -5,7 +5,9 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#ifndef __cplusplus +#ifdef __cplusplus +extern "C" { +#endif static __inline __attribute__((__always_inline__,__gnu_inline__)) int __fortify_FD_CLR(int fd, fd_set *set) @@ -32,6 +34,8 @@ int __fortify_FD_SET(int fd, fd_set *set) #undef FD_SET #define FD_SET(fd, set) __fortify_FD_SET(fd, set) +#ifdef __cplusplus +} #endif #endif diff --git a/include/sys/socket.h b/include/sys/socket.h @@ -5,7 +5,10 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#ifndef __cplusplus +#ifdef __cplusplus +extern "C" { +#endif + #undef recv #undef recvfrom #undef send @@ -61,6 +64,8 @@ ssize_t sendto(int sockfd, const void *buf, size_t n, int flags, return __sendto_orig(sockfd, buf, n, flags, sa, salen); } +#ifdef __cplusplus +} #endif #endif diff --git a/include/unistd.h b/include/unistd.h @@ -5,7 +5,10 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#ifndef __cplusplus +#ifdef __cplusplus +extern "C" { +#endif + #undef confstr #undef getcwd #undef getgroups @@ -165,6 +168,8 @@ ssize_t write(int fd, const void *buf, size_t n) return __write_orig(fd, buf, n); } +#ifdef __cplusplus +} #endif #endif diff --git a/include/wchar.h b/include/wchar.h @@ -6,7 +6,10 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#ifndef __cplusplus +#ifdef __cplusplus +extern "C" { +#endif + #undef fgetws #undef mbsnrtowcs #undef mbsrtowcs @@ -246,6 +249,8 @@ wchar_t *wmemset(wchar_t *s, wchar_t c, size_t n) return __wmemset_orig(s, c, n); } +#ifdef __cplusplus +} #endif #endif