This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[rfa] fix invidious casting bug in infptrace.c with 64-bit CORE_ADDR


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]