From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2716 invoked by alias); 19 Mar 2013 14:44:22 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 2707 invoked by uid 89); 19 Mar 2013 14:44:22 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 19 Mar 2013 14:44:16 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id C70D65203F8; Tue, 19 Mar 2013 15:44:13 +0100 (CET) Date: Tue, 19 Mar 2013 14:51:00 -0000 From: Corinna Vinschen To: gdb-patches@sourceware.org Subject: [patch] windows-nat.c: Fix type of local variable Message-ID: <20130319144413.GR3003@calimero.vinschen.de> Reply-To: gdb-patches@sourceware.org Mail-Followup-To: gdb-patches@sourceware.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2013-03/txt/msg00711.txt.bz2 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