This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH]Fix that GDB will get hang on Windows when using pipe to get stdout and stderr from stub
- From: Eli Zaretskii <eliz at gnu dot org>
- To: Terry Guo <terry dot guo at arm dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 12 Jul 2012 08:19:48 +0300
- Subject: Re: [PATCH]Fix that GDB will get hang on Windows when using pipe to get stdout and stderr from stub
- 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>
- Reply-to: Eli Zaretskii <eliz at gnu dot org>
> From: "Terry Guo" <terry.guo@arm.com>
> Cc: <gdb-patches@sourceware.org>
> 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.