diff options
| author | sin | 2015-03-03 18:13:14 +0000 |
|---|---|---|
| committer | sin | 2015-03-03 18:13:14 +0000 |
| commit | a810ecae686ae9133862a7ed4deabebc93d47b10 (patch) | |
| tree | 5cfe151f5a6547975378e22559d42b731bbfdb55 /include | |
| parent | 4514109df1b70fa24d30b3775db78e118cca4335 (diff) | |
Add wmemset() check
Diffstat (limited to 'include')
| -rw-r--r-- | include/wchar.h | 13 |
1 files changed, 13 insertions, 0 deletions
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) | |||
| 16 | return fgetws(s, n, fp); | 16 | return fgetws(s, n, fp); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | static inline __attribute__ ((always_inline)) | ||
| 20 | wchar_t * | ||
| 21 | __fortify_wmemset(wchar_t *s, wchar_t c, size_t n) | ||
| 22 | { | ||
| 23 | size_t bos = __builtin_object_size(s, 0); | ||
| 24 | |||
| 25 | if (n > bos / sizeof(wchar_t)) | ||
| 26 | __builtin_trap(); | ||
| 27 | return wmemset(s, c, n); | ||
| 28 | } | ||
| 29 | |||
| 19 | #undef fgetws | 30 | #undef fgetws |
| 20 | #define fgetws(s, n, fp) __fortify_fgetws(s, n, fp) | 31 | #define fgetws(s, n, fp) __fortify_fgetws(s, n, fp) |
| 32 | #undef wmemset | ||
| 33 | #define wmemset(s, c, n) __fortify_wmemset(s, c, n) | ||
| 21 | 34 | ||
| 22 | #endif | 35 | #endif |
| 23 | 36 | ||
