This is the mail archive of the gdb-prs@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]
Other format: [Raw text]

gdb/817: Implementation of Win32 child_xfer_memory not safe


>Number:         817
>Category:       gdb
>Synopsis:       Implementation of Win32 child_xfer_memory not safe
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 10 10:38:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     obry@gnat.com
>Release:        GDB 5.x
>Organization:
>Environment:
Windows
>Description:
The child_xfer_memory (in win32-nat.c) is not right. In the Microsoft documentation there is nothing said about the returned value in variable done when the call failed.
>How-To-Repeat:
No real bug found, just found this while reading code to fix the problem with GDB and DLL [#780].
>Fix:
*** win32-nat.c.orig	Sat Nov  9 21:28:52 2002
--- win32-nat.c	Sat Nov  9 23:13:49 2002
***************
*** 1366,1385 ****
  		   struct target_ops *target)
  {
    DWORD done;
    if (write)
      {
        DEBUG_MEM (("gdb: write target memory, %d bytes at 0x%08lx\n",
  		  len, (DWORD) memaddr));
!       WriteProcessMemory (current_process_handle, (LPVOID) memaddr, our,
! 			  len, &done);
        FlushInstructionCache (current_process_handle, (LPCVOID) memaddr, len);
      }
    else
      {
        DEBUG_MEM (("gdb: read target memory, %d bytes at 0x%08lx\n",
  		  len, (DWORD) memaddr));
!       ReadProcessMemory (current_process_handle, (LPCVOID) memaddr, our, len,
! 			 &done);
      }
    return done;
  }
--- 1374,1398 ----
  		   struct target_ops *target)
  {
    DWORD done;
+ 
    if (write)
      {
        DEBUG_MEM (("gdb: write target memory, %d bytes at 0x%08lx\n",
  		  len, (DWORD) memaddr));
!       if (WriteProcessMemory (current_process_handle, (LPVOID) memaddr, our,
! 			      len, &done) == FALSE)
! 	done = 0;
! 
        FlushInstructionCache (current_process_handle, (LPCVOID) memaddr, len);
      }
    else
      {
        DEBUG_MEM (("gdb: read target memory, %d bytes at 0x%08lx\n",
  		  len, (DWORD) memaddr));
! 
!       if (ReadProcessMemory (current_process_handle, (LPCVOID) memaddr, our, 
! 			     (SIZE_T)len, &done) == FALSE)
! 	done = 0;
      }
    return done;
  }
>Release-Note:
>Audit-Trail:
>Unformatted:


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