This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[rfa] fix invidious casting bug in infptrace.c with 64-bit CORE_ADDR
- To: gdb-patches at sources dot redhat dot com
- Subject: [rfa] fix invidious casting bug in infptrace.c with 64-bit CORE_ADDR
- From: Daniel Jacobowitz <dmj+ at andrew dot cmu dot edu>
- Date: Wed, 25 Jul 2001 17:30:40 -0700
This causes all sorts of interesting problems if memaddr happens to be, say,
0x17fffff00 (i.e. 33 bits). There's something else wrong that memaddr was
so large, since ptrace on MIPS/Linux will truncate it back to 32-bit anyway,
but we still shouldn't let this happen. memaddr and addr end up 4G apart,
and count is unimaginably too large.
OK to commit?
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
2001-07-25 Daniel Jacobowitz <drow@mvista.com>
* infptrace.c (child_xfer_memory): Add cast to CORE_ADDR.
Index: infptrace.c
===================================================================
RCS file: /cvs/src/src/gdb/infptrace.c,v
retrieving revision 1.16
diff -u -r1.16 infptrace.c
--- infptrace.c 2001/06/15 23:50:46 1.16
+++ infptrace.c 2001/07/26 00:26:56
@@ -497,7 +497,7 @@
{
register int i;
/* Round starting address down to longword boundary. */
- register CORE_ADDR addr = memaddr & -sizeof (PTRACE_XFER_TYPE);
+ register CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (PTRACE_XFER_TYPE);
/* Round ending address up; get number of longwords that makes. */
register int count
= (((memaddr + len) - addr) + sizeof (PTRACE_XFER_TYPE) - 1)