2015-03-11 18:55:51 +00:00
|
|
|
#ifndef _FORTIFY_STRINGS_H
|
|
|
|
#define _FORTIFY_STRINGS_H
|
2015-01-29 10:43:00 +00:00
|
|
|
|
|
|
|
#include_next <strings.h>
|
|
|
|
|
|
|
|
#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
|
|
|
|
|
2015-03-11 11:18:31 +00:00
|
|
|
#ifndef __cplusplus
|
2015-03-11 09:26:11 +00:00
|
|
|
|
2015-01-29 10:43:00 +00:00
|
|
|
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \
|
|
|
|
|| (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
|
|
|
|
|| (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
|
|
|
|
static inline __attribute__ ((always_inline))
|
2015-01-29 11:10:04 +00:00
|
|
|
void
|
2015-01-30 16:25:13 +00:00
|
|
|
__fortify_bcopy(const void *src, void *dest, size_t n)
|
2015-01-29 10:43:00 +00:00
|
|
|
{
|
|
|
|
size_t bos = __builtin_object_size(dest, 0);
|
|
|
|
|
|
|
|
if (n > bos)
|
|
|
|
__builtin_trap();
|
|
|
|
return bcopy(src, dest, n);
|
|
|
|
}
|
|
|
|
|
2015-01-29 12:14:06 +00:00
|
|
|
static inline __attribute__ ((always_inline))
|
|
|
|
void
|
|
|
|
__fortify_bzero(void *src, size_t n)
|
|
|
|
{
|
|
|
|
size_t bos = __builtin_object_size(src, 0);
|
|
|
|
|
|
|
|
if (n > bos)
|
|
|
|
__builtin_trap();
|
|
|
|
return bzero(src, n);
|
|
|
|
}
|
|
|
|
|
2015-01-29 10:43:00 +00:00
|
|
|
#undef bcopy
|
|
|
|
#define bcopy(src, dest, n) __fortify_bcopy(src, dest, n)
|
2015-01-29 12:14:06 +00:00
|
|
|
#undef bzero
|
|
|
|
#define bzero(src, n) __fortify_bzero(src, n)
|
2015-01-29 10:43:00 +00:00
|
|
|
#endif
|
|
|
|
|
2015-03-11 09:26:11 +00:00
|
|
|
#endif
|
|
|
|
|
2015-01-29 10:43:00 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|