Add wmemcpy() and wmemmove() checks
This commit is contained in:
parent
a810ecae68
commit
f0efb87f8f
|
@ -16,6 +16,28 @@ __fortify_fgetws(wchar_t *s, int n, FILE *fp)
|
||||||
return fgetws(s, n, fp);
|
return fgetws(s, n, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline __attribute__ ((always_inline))
|
||||||
|
wchar_t *
|
||||||
|
__fortify_wmemcpy(wchar_t *d, const wchar_t *s, size_t n)
|
||||||
|
{
|
||||||
|
size_t bos = __builtin_object_size(d, 0);
|
||||||
|
|
||||||
|
if (n > bos / sizeof(wchar_t))
|
||||||
|
__builtin_trap();
|
||||||
|
return wmemcpy(d, s, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __attribute__ ((always_inline))
|
||||||
|
wchar_t *
|
||||||
|
__fortify_wmemmove(wchar_t *d, const wchar_t *s, size_t n)
|
||||||
|
{
|
||||||
|
size_t bos = __builtin_object_size(d, 0);
|
||||||
|
|
||||||
|
if (n > bos / sizeof(wchar_t))
|
||||||
|
__builtin_trap();
|
||||||
|
return wmemmove(d, s, n);
|
||||||
|
}
|
||||||
|
|
||||||
static inline __attribute__ ((always_inline))
|
static inline __attribute__ ((always_inline))
|
||||||
wchar_t *
|
wchar_t *
|
||||||
__fortify_wmemset(wchar_t *s, wchar_t c, size_t n)
|
__fortify_wmemset(wchar_t *s, wchar_t c, size_t n)
|
||||||
|
@ -29,6 +51,10 @@ __fortify_wmemset(wchar_t *s, wchar_t c, size_t n)
|
||||||
|
|
||||||
#undef fgetws
|
#undef fgetws
|
||||||
#define fgetws(s, n, fp) __fortify_fgetws(s, n, fp)
|
#define fgetws(s, n, fp) __fortify_fgetws(s, n, fp)
|
||||||
|
#undef wmemcpy
|
||||||
|
#define wmemcpy(d, s, n) __fortify_wmemcpy(d, s, n)
|
||||||
|
#undef wmemmove
|
||||||
|
#define wmemmove(d, s, n) __fortify_wmemmove(d, s, n)
|
||||||
#undef wmemset
|
#undef wmemset
|
||||||
#define wmemset(s, c, n) __fortify_wmemset(s, c, n)
|
#define wmemset(s, c, n) __fortify_wmemset(s, c, n)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue