From a810ecae686ae9133862a7ed4deabebc93d47b10 Mon Sep 17 00:00:00 2001 From: sin Date: Tue, 3 Mar 2015 18:13:14 +0000 Subject: Add wmemset() check --- include/wchar.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/wchar.h') diff --git a/include/wchar.h b/include/wchar.h index fe2bcfc..54df2be 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -16,8 +16,21 @@ __fortify_fgetws(wchar_t *s, int n, FILE *fp) return fgetws(s, n, fp); } +static inline __attribute__ ((always_inline)) +wchar_t * +__fortify_wmemset(wchar_t *s, wchar_t c, size_t n) +{ + size_t bos = __builtin_object_size(s, 0); + + if (n > bos / sizeof(wchar_t)) + __builtin_trap(); + return wmemset(s, c, n); +} + #undef fgetws #define fgetws(s, n, fp) __fortify_fgetws(s, n, fp) +#undef wmemset +#define wmemset(s, c, n) __fortify_wmemset(s, c, n) #endif -- cgit v1.3