From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29641 invoked by alias); 12 Jul 2012 05:20:15 -0000 Received: (qmail 29627 invoked by uid 22791); 12 Jul 2012 05:20:13 -0000 X-SWARE-Spam-Status: No, hits=-4.2 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_NO,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from mtaout21.012.net.il (HELO mtaout21.012.net.il) (80.179.55.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 12 Jul 2012 05:19:56 +0000 Received: from conversion-daemon.a-mtaout21.012.net.il by a-mtaout21.012.net.il (HyperSendmail v2007.08) id <0M7100I0082ZFQ00@a-mtaout21.012.net.il> for gdb-patches@sourceware.org; Thu, 12 Jul 2012 08:19:54 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.210.75]) by a-mtaout21.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M7100ITQ8525RA0@a-mtaout21.012.net.il>; Thu, 12 Jul 2012 08:19:50 +0300 (IDT) Date: Thu, 12 Jul 2012 05:20:00 -0000 From: Eli Zaretskii Subject: Re: [PATCH]Fix that GDB will get hang on Windows when using pipe to get stdout and stderr from stub In-reply-to: <000301cd5fcf$838d31b0$8aa79510$%guo@arm.com> To: Terry Guo Cc: gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <83ehohblor.fsf@gnu.org> References: <000001cd5338$ded61b20$9c825160$%guo@arm.com> <83hatw8zn1.fsf@gnu.org> <000301cd59bd$ce1c8900$6a559b00$%guo@arm.com> <000101cd5f22$2371cdc0$6a556940$%guo@arm.com> <83k3yab0x6.fsf@gnu.org> <000301cd5fcf$838d31b0$8aa79510$%guo@arm.com> X-IsSubscribed: yes 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 X-SW-Source: 2012-07/txt/msg00152.txt.bz2 > From: "Terry Guo" > Cc: > Date: Thu, 12 Jul 2012 09:41:51 +0800 > > Changes are about code secure and readability. No functionality change. > > 1). Previously I have code: > > char buf[81]; > int to_read = 80; > > Now I change it to: > > #define GDB_MI_MSG_WIDTH 80 > > char buf[GDB_MI_MSG_WIDTH + 1]; > int to_read = GDB_MI_MSG_WIDTH; > > 2). Another change is to add string length check. It is: > > s = read (scb->error_fd, &buf, to_read); > > if ((s == -1) || (s == 0 && !close_fd)) > break > > if (s == 0 && close_fd) > { > .... > } > > /* Current patch add this new line to check length */ > gdb_assert (s > 0 && s <= GDB_MI_MSG_WIDTH); > > buf[s] = '\0'; Thanks. These are all no-brainers, so I think the patch is still good to go in.