commit a810ecae686ae9133862a7ed4deabebc93d47b10
parent 4514109df1b70fa24d30b3775db78e118cca4335
Author: sin <sin@2f30.org>
Date: Tue, 3 Mar 2015 18:13:14 +0000
Add wmemset() check
Diffstat:
1 file changed, 13 insertions(+), 0 deletions(-)
diff --git 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