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

Carlos Palminha CARLOS.PALMINHA at synopsys.com
Mon Aug 7 12:38:55 CDT 2017



On 07-08-2017 18:14, Józef Kucia wrote:
> On Mon, Aug 7, 2017 at 6:48 PM, Carlos Palminha
> <CARLOS.PALMINHA at synopsys.com> wrote:
>> Fixed some nasty unhandled exceptions when loading libraries
>> that don't have .dll extension.
>>
>> Problem was caused by wrong string size calculation.
>>
>> 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..8fc464bcd7 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) )))
> 
> This doesn't look right. After the change it allocates less memory
> than before. Notice that strlenW(dllW) == 4 and sizeof(dllW) == 10.
yep... just spot it.
somehow like already fixes my issues. 

will send a v2.
> 
>>              return STATUS_NO_MEMORY;
>>          strcpyW( dllname, libname );
>>          strcatW( dllname, dllW );
>> --
>> 2.11.0
>>
>>
>>
> 
> 



More information about the wine-devel mailing list