diff options
| author | sin | 2015-03-04 18:26:59 +0000 |
|---|---|---|
| committer | sin | 2015-03-04 19:58:48 +0000 |
| commit | 4ddbe16d881bb8ea70f63ea55f92fa5bb4c7802d (patch) | |
| tree | 5e5cd7372cd2589a83a2f50ba58cdec1e9116537 /include/wchar.h | |
| parent | 7392bcaef8dfdfba67253f3b84f1f1a611e7bab3 (diff) | |
Fix mbsrtowcs() check
Diffstat (limited to 'include/wchar.h')
| -rw-r--r-- | include/wchar.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/include/wchar.h b/include/wchar.h index 9e5413f..78485c0 100644 --- a/include/wchar.h +++ b/include/wchar.h | |||
| @@ -41,10 +41,13 @@ __fortify_mbsrtowcs(wchar_t *d, const char **s, | |||
| 41 | size_t wn, mbstate_t *st) | 41 | size_t wn, mbstate_t *st) |
| 42 | { | 42 | { |
| 43 | size_t bos = __builtin_object_size(d, 0); | 43 | size_t bos = __builtin_object_size(d, 0); |
| 44 | size_t r; | ||
| 44 | 45 | ||
| 45 | if (wn > bos / sizeof(wchar_t)) | 46 | bos /= sizeof(wchar_t); |
| 47 | r = mbsrtowcs(d, s, wn > bos ? bos : wn, st); | ||
| 48 | if (bos < wn && d && *s && r != (size_t)-1) | ||
| 46 | __builtin_trap(); | 49 | __builtin_trap(); |
| 47 | return mbsrtowcs(d, s, wn, st); | 50 | return r; |
| 48 | } | 51 | } |
| 49 | 52 | ||
| 50 | static inline __attribute__ ((always_inline)) | 53 | static inline __attribute__ ((always_inline)) |
