[PATCH] kernelbase: Fix GetEnvironmentVariableA with multi-byte strings.
Alexandre Julliard
julliard at winehq.org
Fri Aug 7 11:01:30 CDT 2020
Gijs Vermeulen <gijsvrm at gmail.com> writes:
> From: Vladimir Panteleev <git at vladimir.panteleev.md>
>
> The previous implementation of GetEnvironmentVariableA incorrectly
> assumed that, after WideCharToMultiByte conversion, the resulting A
> string will have the same number of CHARs as the number of WCHARs in
> the W string. This assumption resulted in failures when querying
> environment variables with non-ASCII values in locales with multi-byte
> character pages.
>
> Address this by always retrieving the Unicode value of the variable,
> then measuring its length after code page conversion, and only then
> deciding whether it fits into the user-supplied buffer.
The problem is that you are now retrieving it twice, and the value may
have changed in the meantime.
--
Alexandre Julliard
julliard at winehq.org
More information about the wine-devel
mailing list