This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] windows-nat.c: Fix type of local variable
- From: Corinna Vinschen <vinschen at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 19 Mar 2013 15:44:13 +0100
- Subject: [patch] windows-nat.c: Fix type of local variable
- Reply-to: gdb-patches at sourceware dot org
Hi,
the below patch fixes a crash on x86_64 Cygwin.
The call to ReadProcessMemory takes a SIZE_T* as fifth parameter.
SIZE_T is 64 bit on x86_64. However, the local variable `n' is defined
as DWORD, which is only 32 bit. Therefore, when ReadProcessMemory
returns, 32 unrelated bits on the stack are overwritten. On x86_64
Cygwin that's the lower 32 bits of the local variable `'s'. The
following xfree(s) call then SEGVs. Other calls to ReadProcessMemory
in the same file already use a SIZE_T variable in that place.
Ok to apply?
Thanks,
Corinna
* windows-nat.c (handle_output_debug_string): Change type of n to
SIZE_T to avoid crash on 64 bit systems.
Index: windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-nat.c,v
retrieving revision 1.241
diff -u -p -r1.241 windows-nat.c
--- windows-nat.c 27 Feb 2013 19:42:26 -0000 1.241
+++ windows-nat.c 19 Mar 2013 14:43:03 -0000
@@ -973,7 +973,7 @@ handle_output_debug_string (struct targe
if (gotasig)
{
LPCVOID x;
- DWORD n;
+ SIZE_T n;
ourstatus->kind = TARGET_WAITKIND_STOPPED;
retval = strtoul (p, &p, 0);
if (!retval)
--
Corinna Vinschen
Cygwin Maintainer
Red Hat