Commit 74ec9773 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ntdll: Use a dynamically allocated buffer in find_forwarded_export() if necessary.

parent 97504067
...@@ -608,19 +608,20 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWS ...@@ -608,19 +608,20 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWS
const IMAGE_EXPORT_DIRECTORY *exports; const IMAGE_EXPORT_DIRECTORY *exports;
DWORD exp_size; DWORD exp_size;
WINE_MODREF *wm; WINE_MODREF *wm;
WCHAR mod_name[32]; WCHAR buffer[32], *mod_name = buffer;
const char *end = strrchr(forward, '.'); const char *end = strrchr(forward, '.');
FARPROC proc = NULL; FARPROC proc = NULL;
if (!end) return NULL; if (!end) return NULL;
if ((end - forward) * sizeof(WCHAR) >= sizeof(mod_name)) return NULL; if ((end - forward) * sizeof(WCHAR) > sizeof(buffer) - sizeof(dllW))
{
if (!(mod_name = RtlAllocateHeap( GetProcessHeap(), 0, (end - forward + sizeof(dllW)) * sizeof(WCHAR) )))
return NULL;
}
ascii_to_unicode( mod_name, forward, end - forward ); ascii_to_unicode( mod_name, forward, end - forward );
mod_name[end - forward] = 0; mod_name[end - forward] = 0;
if (!wcschr( mod_name, '.' )) if (!wcschr( mod_name, '.' ))
{
if ((end - forward) * sizeof(WCHAR) >= sizeof(mod_name) - sizeof(dllW)) return NULL;
memcpy( mod_name + (end - forward), dllW, sizeof(dllW) ); memcpy( mod_name + (end - forward), dllW, sizeof(dllW) );
}
if (!(wm = find_basename_module( mod_name ))) if (!(wm = find_basename_module( mod_name )))
{ {
...@@ -642,6 +643,7 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWS ...@@ -642,6 +643,7 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWS
if (!wm) if (!wm)
{ {
if (mod_name != buffer) RtlFreeHeap( GetProcessHeap(), 0, mod_name );
ERR( "module not found for forward '%s' used by %s\n", ERR( "module not found for forward '%s' used by %s\n",
forward, debugstr_w(get_modref(module)->ldr.FullDllName.Buffer) ); forward, debugstr_w(get_modref(module)->ldr.FullDllName.Buffer) );
return NULL; return NULL;
...@@ -664,6 +666,7 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWS ...@@ -664,6 +666,7 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWS
forward, debugstr_w(get_modref(module)->ldr.FullDllName.Buffer), forward, debugstr_w(get_modref(module)->ldr.FullDllName.Buffer),
debugstr_w(get_modref(module)->ldr.BaseDllName.Buffer) ); debugstr_w(get_modref(module)->ldr.BaseDllName.Buffer) );
} }
if (mod_name != buffer) RtlFreeHeap( GetProcessHeap(), 0, mod_name );
return proc; return proc;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment