diff options
| -rw-r--r-- | include/wchar.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/wchar.h b/include/wchar.h new file mode 100644 index 0000000..fe2bcfc --- /dev/null +++ b/include/wchar.h | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | #ifndef FORTIFY_WCHAR_H_ | ||
| 2 | #define FORTIFY_WCHAR_H_ | ||
| 3 | |||
| 4 | #include_next <wchar.h> | ||
| 5 | |||
| 6 | #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 | ||
| 7 | |||
| 8 | static inline __attribute__ ((always_inline)) | ||
| 9 | wchar_t * | ||
| 10 | __fortify_fgetws(wchar_t *s, int n, FILE *fp) | ||
| 11 | { | ||
| 12 | size_t bos = __builtin_object_size(s, 0); | ||
| 13 | |||
| 14 | if ((size_t)n > bos / sizeof(wchar_t)) | ||
| 15 | __builtin_trap(); | ||
| 16 | return fgetws(s, n, fp); | ||
| 17 | } | ||
| 18 | |||
| 19 | #undef fgetws | ||
| 20 | #define fgetws(s, n, fp) __fortify_fgetws(s, n, fp) | ||
| 21 | |||
| 22 | #endif | ||
| 23 | |||
| 24 | #endif | ||
