Cygwin: wcsxfrm_l: Only byte swap if dest size is > 0
commit c0d7d3e1a2fa96db15613cbd68a68c96966bc402 removed the usage of the LCMAP_BYTEREV flag in the call to LCMapStringW to workaround a strange bug in LCMapStringW. This patch didn't take a userspace call of wcsxfrm{_l} with NULL buffer and 0 size to evaluate the required buffer size into account. This introduced a crash trying to byte swap the NULL buffer. This patch fixes that problem. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
62c66a39bd
commit
10900b98d1
@ -1204,6 +1204,8 @@ wcsxfrm_l (wchar_t *__restrict ws1, const wchar_t *__restrict ws2, size_t wsn,
|
|||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
ret /= sizeof (wchar_t);
|
ret /= sizeof (wchar_t);
|
||||||
|
if (wsn)
|
||||||
|
{
|
||||||
/* Byte swap the array ourselves here. */
|
/* Byte swap the array ourselves here. */
|
||||||
for (size_t idx = 0; idx < ret; ++idx)
|
for (size_t idx = 0; idx < ret; ++idx)
|
||||||
ws1[idx] = __builtin_bswap16 (ws1[idx]);
|
ws1[idx] = __builtin_bswap16 (ws1[idx]);
|
||||||
@ -1213,6 +1215,7 @@ wcsxfrm_l (wchar_t *__restrict ws1, const wchar_t *__restrict ws2, size_t wsn,
|
|||||||
the result is wchar_t-NUL terminated. */
|
the result is wchar_t-NUL terminated. */
|
||||||
if (ret < wsn)
|
if (ret < wsn)
|
||||||
ws1[ret] = L'\0';
|
ws1[ret] = L'\0';
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if (GetLastError () != ERROR_INSUFFICIENT_BUFFER)
|
if (GetLastError () != ERROR_INSUFFICIENT_BUFFER)
|
||||||
|
@ -11,3 +11,6 @@ Bug Fixes
|
|||||||
|
|
||||||
- Fix /proc/version after uname change
|
- Fix /proc/version after uname change
|
||||||
Addresses: https://cygwin.com/ml/cygwin/2019-03/msg00467.html
|
Addresses: https://cygwin.com/ml/cygwin/2019-03/msg00467.html
|
||||||
|
|
||||||
|
- Fix a crash in wcsxfrm_l if destination size is 0.
|
||||||
|
Addresses: https://cygwin.com/ml/cygwin/2019-03/msg00492.html
|
||||||
|
Loading…
x
Reference in New Issue
Block a user