summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsin2015-03-03 18:16:29 +0000
committersin2015-03-03 18:16:29 +0000
commitf0efb87f8f5a0cc64b386ed6be4f9c2db328c37b (patch)
treebb48f65df011be1878f9ff2084c8802100ea66db
parenta810ecae686ae9133862a7ed4deabebc93d47b10 (diff)
Add wmemcpy() and wmemmove() checks
-rw-r--r--include/wchar.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/wchar.h b/include/wchar.h
index 54df2be..9360eb5 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -18,6 +18,28 @@ __fortify_fgetws(wchar_t *s, int n, FILE *fp)
18 18
19static inline __attribute__ ((always_inline)) 19static inline __attribute__ ((always_inline))
20wchar_t * 20wchar_t *
21__fortify_wmemcpy(wchar_t *d, const wchar_t *s, size_t n)
22{
23 size_t bos = __builtin_object_size(d, 0);
24
25 if (n > bos / sizeof(wchar_t))
26 __builtin_trap();
27 return wmemcpy(d, s, n);
28}
29
30static inline __attribute__ ((always_inline))
31wchar_t *
32__fortify_wmemmove(wchar_t *d, const wchar_t *s, size_t n)
33{
34 size_t bos = __builtin_object_size(d, 0);
35
36 if (n > bos / sizeof(wchar_t))
37 __builtin_trap();
38 return wmemmove(d, s, n);
39}
40
41static inline __attribute__ ((always_inline))
42wchar_t *
21__fortify_wmemset(wchar_t *s, wchar_t c, size_t n) 43__fortify_wmemset(wchar_t *s, wchar_t c, size_t n)
22{ 44{
23 size_t bos = __builtin_object_size(s, 0); 45 size_t bos = __builtin_object_size(s, 0);
@@ -29,6 +51,10 @@ __fortify_wmemset(wchar_t *s, wchar_t c, size_t n)
29 51
30#undef fgetws 52#undef fgetws
31#define fgetws(s, n, fp) __fortify_fgetws(s, n, fp) 53#define fgetws(s, n, fp) __fortify_fgetws(s, n, fp)
54#undef wmemcpy
55#define wmemcpy(d, s, n) __fortify_wmemcpy(d, s, n)
56#undef wmemmove
57#define wmemmove(d, s, n) __fortify_wmemmove(d, s, n)
32#undef wmemset 58#undef wmemset
33#define wmemset(s, c, n) __fortify_wmemset(s, c, n) 59#define wmemset(s, c, n) __fortify_wmemset(s, c, n)
34 60