Eric van Beurden : dbghelp: Prevent huge minidumps by ensuring the memory range is clamped.
Alexandre Julliard
julliard at winehq.org
Fri Jan 18 06:34:07 CST 2008
Module: wine
Branch: master
Commit: cb9596484d37dc4ea3027851c88a048405cd35c0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=cb9596484d37dc4ea3027851c88a048405cd35c0
Author: Eric van Beurden <ericvb at transgaming.com>
Date: Thu Jan 17 17:31:49 2008 -0500
dbghelp: Prevent huge minidumps by ensuring the memory range is clamped.
---
dlls/dbghelp/minidump.c | 42 ++++++++++++++++++++++++++++++++++++------
1 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/dlls/dbghelp/minidump.c b/dlls/dbghelp/minidump.c
index 3dd69cf..9ae5307 100644
--- a/dlls/dbghelp/minidump.c
+++ b/dlls/dbghelp/minidump.c
@@ -119,20 +119,50 @@ static void fetch_thread_stack(struct dump_context* dc, const void* teb_addr,
{
#ifdef __i386__
/* limiting the stack dumping to the size actually used */
- if (ctx->Esp)
- mmd->StartOfMemoryRange = (ctx->Esp - 4);
+ if (ctx->Esp){
+
+ /* make sure ESP is within the established range of the stack. It could have
+ been clobbered by whatever caused the original exception. */
+ if (ctx->Esp - 4 < (ULONG_PTR)tib.StackLimit || ctx->Esp - 4 > (ULONG_PTR)tib.StackBase)
+ mmd->StartOfMemoryRange = (ULONG_PTR)tib.StackLimit;
+
+ else
+ mmd->StartOfMemoryRange = (ctx->Esp - 4);
+ }
+
else
mmd->StartOfMemoryRange = (ULONG_PTR)tib.StackLimit;
+
#elif defined(__powerpc__)
- if (ctx->Iar)
- mmd->StartOfMemoryRange = ctx->Iar - 4;
+ if (ctx->Iar){
+
+ /* make sure IAR is within the established range of the stack. It could have
+ been clobbered by whatever caused the original exception. */
+ if (ctx->Iar - 4 < (ULONG_PTR)tib.StackLimit || ctx->Iar - 4 > (ULONG_PTR)tib.StackBase)
+ mmd->StartOfMemoryRange = (ULONG_PTR)tib.StackLimit;
+
+ else
+ mmd->StartOfMemoryRange = (ctx->Iar - 4);
+ }
+
else
mmd->StartOfMemoryRange = (ULONG_PTR)tib.StackLimit;
+
#elif defined(__x86_64__)
- if (ctx->Rsp)
- mmd->StartOfMemoryRange = (ctx->Rsp - 8);
+ if (ctx->Rsp){
+
+ /* make sure RSP is within the established range of the stack. It could have
+ been clobbered by whatever caused the original exception. */
+ if (ctx->Rsp - 8 < (ULONG_PTR)tib.StackLimit || ctx->Rsp - 8 > (ULONG_PTR)tib.StackBase)
+ mmd->StartOfMemoryRange = (ULONG_PTR)tib.StackLimit;
+
+ else
+ mmd->StartOfMemoryRange = (ctx->Rsp - 8);
+ }
+
else
mmd->StartOfMemoryRange = (ULONG_PTR)tib.StackLimit;
+
#else
#error unsupported CPU
#endif
More information about the wine-cvs
mailing list