[PATCH v2] ntdll: Fix wrong string size alloc when loading libraries

Carlos Palminha CARLOS.PALMINHA at synopsys.com
Mon Aug 7 17:43:48 CDT 2017



On 07-08-2017 19:55, Nikolay Sivov wrote:
> On 07.08.2017 20:41, Carlos Palminha wrote:
>> Fixed some nasty unhandled exceptions when loading libraries
>> that don't have .dll extension.
>>
>> Problem was caused by wrong string size calculation.
>>
>> v2: Now properly takes into account strlen * sizeof WCHAR
>>
>> Signed-off-by: Carlos Palminha <palminha at synopsys.com>
>> ---
>>  dlls/ntdll/loader.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
>> index dd1f74c0fc..83dd6d378e 100644
>> --- a/dlls/ntdll/loader.c
>> +++ b/dlls/ntdll/loader.c
>> @@ -2141,7 +2141,7 @@ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname,
>>      if (!(ext = strrchrW( libname, '.')) || strchrW( ext, '/' ) || strchrW( ext, '\\'))
>>      {
>>          if (!(dllname = RtlAllocateHeap( GetProcessHeap(), 0,
>> -                                         (strlenW(libname) * sizeof(WCHAR)) + sizeof(dllW) )))
>> +                                         (strlenW(libname) * sizeof(WCHAR)) + (strlenW(dllW) * sizeof(WCHAR)) )))
>>              return STATUS_NO_MEMORY;
>>          strcpyW( dllname, libname );
>>          strcatW( dllname, dllW );
>>
> 
> This is still shorter than it is now:
> 
> sizeof(dllW) is 5 * sizeof(WCHAR) vs strlenW(dllW) * sizeof(WCHAR) == 4
> * sizeof(WCHAR).
> 
yep, you are right!

Somehow with my "patch" i stop getting the "Program Error" window with the exception.
But after i realized i still got the exception "silently" in the logs.

Need to better understand why its crashing around that Alloc.

Regards,
C.Palminha



More information about the wine-devel mailing list