diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/fortify-headers.h | 6 | ||||
| -rw-r--r-- | include/string.h | 3 |
2 files changed, 5 insertions, 4 deletions
diff --git a/include/fortify-headers.h b/include/fortify-headers.h index 3eaed7c..bc7bf00 100644 --- a/include/fortify-headers.h +++ b/include/fortify-headers.h | |||
| @@ -106,9 +106,9 @@ | |||
| 106 | #define __diagnose_as_builtin(...) | 106 | #define __diagnose_as_builtin(...) |
| 107 | #endif | 107 | #endif |
| 108 | 108 | ||
| 109 | #if __has_attribute (__diagnose_if) | 109 | #if __has_attribute (diagnose_if) |
| 110 | #define __warning_if(cond, msg) __attribute__ ((__diagnose_if (cond, msg, "warning"))) | 110 | #define __warning_if(cond, msg) __attribute__ ((diagnose_if (cond, msg, "warning"))) |
| 111 | #define __error_if(cond, msg) __attribute__ ((__diagnose_if (cond, msg, "error"))) | 111 | #define __error_if(cond, msg) __attribute__ ((diagnose_if (cond, msg, "error"))) |
| 112 | #else | 112 | #else |
| 113 | #define __warning_if(cond, msg) | 113 | #define __warning_if(cond, msg) |
| 114 | #define __error_if(cond, msg) | 114 | #define __error_if(cond, msg) |
diff --git a/include/string.h b/include/string.h index be13cb4..010b7f2 100644 --- a/include/string.h +++ b/include/string.h | |||
| @@ -43,6 +43,7 @@ __access(read_only, 2, 3) | |||
| 43 | __diagnose_as_builtin(__builtin_memcpy, 1, 2, 3) | 43 | __diagnose_as_builtin(__builtin_memcpy, 1, 2, 3) |
| 44 | _FORTIFY_FN(memcpy) void *memcpy(void * _FORTIFY_POS0 __od, | 44 | _FORTIFY_FN(memcpy) void *memcpy(void * _FORTIFY_POS0 __od, |
| 45 | const void * _FORTIFY_POS0 __os, size_t __n) | 45 | const void * _FORTIFY_POS0 __os, size_t __n) |
| 46 | __error_if((__bos(__od, 0) < __n), "'memcpy' called with `n` bigger than the size of `d`.") | ||
| 46 | { | 47 | { |
| 47 | size_t __bd = __bos(__od, 0); | 48 | size_t __bd = __bos(__od, 0); |
| 48 | size_t __bs = __bos(__os, 0); | 49 | size_t __bs = __bos(__os, 0); |
| @@ -72,8 +73,8 @@ _FORTIFY_FN(memmove) void *memmove(void * _FORTIFY_POS0 __d, | |||
| 72 | 73 | ||
| 73 | __access(write_only, 1, 3) | 74 | __access(write_only, 1, 3) |
| 74 | __diagnose_as_builtin(__builtin_memset, 1, 2, 3) | 75 | __diagnose_as_builtin(__builtin_memset, 1, 2, 3) |
| 75 | __warning_if(__c != 0 && __n == 0, "'memset' will set `0` bytes; did you invert the arguments?") | ||
| 76 | _FORTIFY_FN(memset) void *memset(void * _FORTIFY_POS0 __d, int __c, size_t __n) | 76 | _FORTIFY_FN(memset) void *memset(void * _FORTIFY_POS0 __d, int __c, size_t __n) |
| 77 | __warning_if(__c != 0 && __n == 0, "'memset' will set `0` bytes; did you invert the arguments?") | ||
| 77 | { | 78 | { |
| 78 | size_t __b = __bos(__d, 0); | 79 | size_t __b = __bos(__d, 0); |
| 79 | 80 | ||
