Add mempcpy() checks
This commit is contained in:
父節點
31f2952bc7
當前提交
c49f6215ea
|
@ -102,6 +102,18 @@ char *__fortify_strncpy(char *__restrict dest, const char *__restrict src, size_
|
|||
return strncpy(dest, src, n);
|
||||
}
|
||||
|
||||
#if defined(_GNU_SOURCE)
|
||||
static inline __attribute__ ((always_inline))
|
||||
void *__fortify_mempcpy(void *__restrict dest, const void *__restrict src, size_t n)
|
||||
{
|
||||
size_t bos = __builtin_object_size(dest, 0);
|
||||
|
||||
if (n > bos)
|
||||
__builtin_trap();
|
||||
return mempcpy(dest, src, n);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
||||
static inline __attribute__ ((always_inline))
|
||||
size_t __fortify_strlcat(char *__restrict dest, const char *__restrict src, size_t n)
|
||||
|
@ -143,6 +155,11 @@ size_t __fortify_strlcpy(char *__restrict dest, const char *__restrict src, size
|
|||
#undef strncpy
|
||||
#define strncpy(dest, src, n) __fortify_strcpy(dest, src, n)
|
||||
|
||||
#if defined(_GNU_SOURCE)
|
||||
#undef mempcpy
|
||||
#define mempcpy(dest, src, n) __fortify_mempcpy(dest, src, n)
|
||||
#endif
|
||||
|
||||
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
||||
#undef strlcat
|
||||
#define strlcat(dest, src, n) __fortify_strlcat(dest, src, n)
|
||||
|
|
載入中…
新增問題並參考