commit c51977cfcc0b4d62e4836b4471f760ec3e3936e9
parent 4ddbe16d881bb8ea70f63ea55f92fa5bb4c7802d
Author: sin <sin@2f30.org>
Date: Wed, 4 Mar 2015 20:16:44 +0000
Fix wcsrtombs() check
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/wchar.h b/include/wchar.h
@@ -147,10 +147,12 @@ __fortify_wcsrtombs(char *d, const wchar_t **s, size_t n,
mbstate_t *st)
{
size_t bos = __builtin_object_size(d, 0);
+ size_t r;
- if (n > bos)
+ r = wcsrtombs(d, s, n > bos ? bos : n, st);
+ if (bos < n && d && *s && r != (size_t)-1)
__builtin_trap();
- return wcsrtombs(d, s, n, st);
+ return r;
}
static inline __attribute__ ((always_inline))