From f9a906e786fbca1b0bdfe7d3842610ca87035958 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 22 Aug 2005 15:13:39 +0000 Subject: * stdlib/bits/stdlib.h (mbstowcs): Divide __bos (__dst) by sizeof (wchar_t) rather than multiplying __len by sizeof (wchar_t). Pass __bos (__dst) / sizeof (wchar_t) to the *_chk routine. * wcsmbs/bits/wchar2.h (mbsrtowcs, mbsnrtowcs): Likewise. * debug/mbsnrtowcs_chk.c (__mbsnrtowcs_chk): Don't multiply len by sizeof (wchar_t). * debug/mbsrtowcs_chk.c (__mbsrtowcs_chk): Likewise. * debug/mbstowcs_chk.c (__mbstowcs_chk): Likewise. Fix type of SRC argument. Pass &SRC rather than SRC to __mbsrtowcs. * debug/wcstombs_chk.c (__wcstombs_chk): Pass &SRC rather than SRC to __wcsrtombs. * debug/tst-chk1.c: Include assert.h. (do_test): Change enough array from VLA into a fixed size array. Assert that MB_CUR_MAX is <= sizeof (enough). Use FAIL () macro instead of print error details. Add several new tests. Kill some unused variable warnings. --- wcsmbs/bits/wchar2.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'wcsmbs') diff --git a/wcsmbs/bits/wchar2.h b/wcsmbs/bits/wchar2.h index fba18d9003..6eac952ac9 100644 --- a/wcsmbs/bits/wchar2.h +++ b/wcsmbs/bits/wchar2.h @@ -324,8 +324,9 @@ __NTH (mbsrtowcs (wchar_t *__restrict __dst, __const char **__restrict __src, { if (__bos (__dst) != (size_t) -1 && (!__builtin_constant_p (__len) - || __len * sizeof (wchar_t) > __bos (__dst))) - return __mbsrtowcs_chk (__dst, __src, __len, __ps, __bos (__dst)); + || __len > __bos (__dst) / sizeof (wchar_t))) + return __mbsrtowcs_chk (__dst, __src, __len, __ps, + __bos (__dst) / sizeof (wchar_t)); return __mbsrtowcs_alias (__dst, __src, __len, __ps); } @@ -368,8 +369,9 @@ __NTH (mbsnrtowcs (wchar_t *__restrict __dst, __const char **__restrict __src, { if (__bos (__dst) != (size_t) -1 && (!__builtin_constant_p (__len) - || __len * sizeof (wchar_t) > __bos (__dst))) - return __mbsnrtowcs_chk (__dst, __src, __nmc, __len, __ps, __bos (__dst)); + || __len > __bos (__dst) / sizeof (wchar_t))) + return __mbsnrtowcs_chk (__dst, __src, __nmc, __len, __ps, + __bos (__dst) / sizeof (wchar_t)); return __mbsnrtowcs_alias (__dst, __src, __nmc, __len, __ps); } -- cgit 1.4.1