Since a81c53504ae32715e6e91bd020fdebd5bef20d48, reading the debuggee environment could fail.
Depending on context, it could end up with no longer being able to find ELF/Mach-O modules (as some codepaths get the path to Wine's loader from debuggee environment).
Code was aligning read on allocation granularity, but this can fail when not all the pages within that range are committed. So align on page instead.
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/dbghelp/dbghelp.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/dlls/dbghelp/dbghelp.c b/dlls/dbghelp/dbghelp.c index 3ce3ef6f707..76761e4caf7 100644 --- a/dlls/dbghelp/dbghelp.c +++ b/dlls/dbghelp/dbghelp.c @@ -400,17 +400,13 @@ static BOOL check_live_target(struct process* pcs, BOOL wow64, BOOL child_wow64) { size_t buf_size = 0, i, last_null = -1; WCHAR *buf = NULL; + WCHAR *new_buf;
do { size_t read_size = sysinfo.dwAllocationGranularity - (env & (sysinfo.dwAllocationGranularity - 1)); - if (buf) - { - WCHAR *new_buf; - if (!(new_buf = realloc(buf, buf_size + read_size))) break; - buf = new_buf; - } - else if(!(buf = malloc(read_size))) break; + if (!(new_buf = realloc(buf, buf_size + read_size))) break; + buf = new_buf;
if (!read_process_memory(pcs, env, (char*)buf + buf_size, read_size)) break; for (i = buf_size / sizeof(WCHAR); i < (buf_size + read_size) / sizeof(WCHAR); i++)
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/dbghelp/dbghelp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/dbghelp/dbghelp.c b/dlls/dbghelp/dbghelp.c index 76761e4caf7..b15ece25c88 100644 --- a/dlls/dbghelp/dbghelp.c +++ b/dlls/dbghelp/dbghelp.c @@ -404,7 +404,7 @@ static BOOL check_live_target(struct process* pcs, BOOL wow64, BOOL child_wow64)
do { - size_t read_size = sysinfo.dwAllocationGranularity - (env & (sysinfo.dwAllocationGranularity - 1)); + size_t read_size = sysinfo.dwPageSize - (env & (sysinfo.dwPageSize - 1)); if (!(new_buf = realloc(buf, buf_size + read_size))) break; buf = new_buf;