[PATCH] kernelbase: Fix GetEnvironmentVariableA with multi-byte strings.

jancren at charter.net jancren at charter.net
Fri Aug 7 11:16:02 CDT 2020


P

Sent from my iPhone

> On Aug 7, 2020, at 12:01 PM, Alexandre Julliard <julliard at winehq.org> wrote:
> 
> 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