Commit Graph

44 Commits

Author SHA1 Message Date
sin
5aabc7e6aa Make use of builtins whenever possible 2019-02-25 13:17:08 +00:00
A. Wilcox
a9ffac8596 Don't use __extension__ in C++ code
A few important notes:

*  __extension__ is a GNU C "alternate" keyword, not a C++ keyword.[1]

*  __extension__ is designed to work on "expressions"; it does work on
   #include_next in C mode, but it has no effect in C++ mode; the
   warning will still appear, if enabled, even with __extension__
   preceding #include_next.  This is because #include_next is not
   considered an expression in C++, so the compiler attaches
   __extension__ to the first expression of the header.

All of this leads us to a build failure while building at least all
Mozilla software.  Moz has an alternate -isystem dir searched before
/usr/include that overrides some headers, including <features.h>.  The
first statement in each of these headers is a #pragma, and since
__extension__ is looking for an expression, and #pragma is a "null"
expression, we end up with the following error:

dist/system_wrappers/features.h:1:9: error: '#pragma' is not allowed here

Since __extension__ has no effect on #include_next in C++ mode anyway,
and since it can cause breakage, this commit omits __extension__ in C++
mode.

[1]: https://gcc.gnu.org/onlinedocs/gcc-6.4.0/gcc/Alternate-Keywords.html
2018-07-24 11:00:30 +01:00
sin
2bc423c355 Bump copyright year 2016-09-10 12:54:17 +01:00
sin
edb2ded3af Fix stpncpy() check
Do not crash unless the overflow would happen.
2015-07-15 17:02:27 +01:00
Steven Barth
7fd984fcb5 Add __extension__ mark to include_next to silence -pedantic
Signed-off-by: Steven Barth <steven@midlink.org>
2015-06-25 10:18:26 +01:00
Trutz Behn
1cd5461a53 Use namespace-safe macro, param and variable names 2015-06-03 18:55:35 +01:00
sin
07adb50914 Add LICENSE header 2015-05-13 12:15:36 +01:00
sin
158782b3bb Add fortify_fn() helper in fortify-headers.h 2015-05-13 12:05:29 +01:00
sin
2bd3091b36 Check for out of bound reads for memcpy, memmove and mempcpy() 2015-04-08 15:18:49 +01:00
sin
442a2a4d65 Hide stpcpy() and stpncpy() under feature test macros 2015-03-15 09:57:26 +00:00
Trutz Behn
22e7e51007 Use __typeof__ to in part avoid replicating function types 2015-03-14 20:37:27 +00:00
sin
0932a82ada Explicitly cast pointers to satisfy C++ code 2015-03-14 09:45:37 +00:00
sin
37eb2c9c1d Add __artificial__ to aid in debugging 2015-03-14 09:38:22 +00:00
sin
d12254166a Restore C++ support 2015-03-13 23:09:15 +00:00
sin
9f8c543dc8 Rework fortify implementation to use extern inline
Overriding functions with macros is legal in C but a lot of software
is not prepared for it.  Use the extern inline method to achieve the
same result.
2015-03-13 11:00:46 +00:00
Trutz Behn
b211796d68 Put include guards in the reserved namespace
fortify-headers is considered part of the implementation.
2015-03-11 21:33:01 +00:00
sin
69e43f5c5e Revert "Add explicit casts to satisfy C++ code"
This reverts commit 1fbf7a3a5e9c02cf992848002cfb88c3c7cc0212.
2015-03-11 12:57:37 +00:00
sin
14af218559 Ignore C++ for now
It is not legal to override standard functions using macros in C++.
We may have to revisit this in the future.
2015-03-11 11:18:31 +00:00
sin
8604f138c5 Add ifdef guards for C++ code 2015-03-11 09:26:11 +00:00
sin
1fbf7a3a5e Add explicit casts to satisfy C++ code 2015-03-11 09:21:25 +00:00
sin
499ea65dd5 Revert "Fix invalid conversion in C++ code"
This reverts commit 4b4dfea25d660a8a27e95ea531686001246b3d1e.
2015-03-11 09:21:00 +00:00
sin
4b4dfea25d Fix invalid conversion in C++ code
/usr/include/fortify/string.h: In function 'void* __fortify_memcpy(void*, const void*, size_t)':
/usr/include/fortify/string.h:13:12: error: invalid conversion from 'void*' to 'char*' [-fpermissive]
/usr/include/fortify/string.h:14:18: error: invalid conversion from 'const void*' to 'const char*' [-fpermissive]

Since we are relying on GCC anyway, assume void * arithmetic is OK.
2015-03-11 09:17:56 +00:00
sin
701d7d3303 Fix strncat() and strncpy() mappings
Thanks zhasha.
2015-03-10 16:38:26 +00:00
sin
74ab284496 Clarify comment a bit 2015-02-25 10:35:16 +00:00
sin
eecef18261 Remove compile time checks
These can produce false positives.  Given that we support fortify
source level 1 we shouldn't break valid code.
2015-02-24 18:14:33 +00:00
sin
c1734bf206 Remove header license comments 2015-02-22 09:39:43 +00:00
sin
6e4f53a3f5 Remember to #undef __errordecl
Thanks zhasha for spotting this.
2015-02-04 18:06:57 +00:00
sin
87f56f70d7 Style fix 2015-02-04 15:13:38 +00:00
sin
e4fe187649 Remove __restrict 2015-01-30 16:25:13 +00:00
sin
03289c3954 Fix typo 2015-01-29 20:41:17 +00:00
sin
0784beab02 Allow dest == src in memcpy()
memcpy() needs to accept dest == src for gcc.
struct foo a, b; a = a; might be implemented using memcpy().
2015-01-29 17:55:03 +00:00
sin
474f2887ce Add compile-time checks as well 2015-01-29 12:42:41 +00:00
sin
3d15948020 Add license info 2015-01-29 11:13:07 +00:00
sin
1e306fd642 Trap if memcpy() pointers are overlapping
Maybe this should only be done if _FORTIFY_SOURCE > 1.
2015-01-29 10:56:15 +00:00
sin
f54195479d Use BSD-style func defs 2015-01-28 23:40:17 +00:00
sin
37b438f146 Use #ifdef instead of #if defined 2015-01-28 17:47:08 +00:00
sin
c49f6215ea Add mempcpy() checks 2015-01-28 17:44:38 +00:00
sin
bcc398c14a Simplify checks
Do not perform checks only when `n' is constant, most of the time
it is not.

The bos == (size_t)-1 check is redundant because n > bos
with bos == -1 will always be false.
2015-01-28 17:13:44 +00:00
sin
1872b6a7e5 Remove trailing semicolon 2015-01-28 16:31:19 +00:00
sin
013d07a11c Add stpncpy() 2015-01-28 16:21:38 +00:00
sin
9626051b5d Add stpcpy() 2015-01-28 16:16:23 +00:00
sin
de7999ee82 Move defines to the bottom
This allows us to re-use the functions internally.
2015-01-28 16:07:24 +00:00
sin
6bb34c15b4 Merge __foo_chk() into __fortify_foo() 2015-01-28 15:39:11 +00:00
sin
b258495eba Initial commit 2015-01-28 15:14:49 +00:00