public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Sergio Durigan Junior <sergiodj@redhat.com>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: GDB Patches <gdb-patches@sourceware.org>,
	Pedro Alves <palves@redhat.com>
Subject: Re: [PATCH] Sanitize input_interrupt output
Date: Sun, 28 Dec 2014 03:01:00 -0000	[thread overview]
Message-ID: <87lhlslbqg.fsf@redhat.com> (raw)
In-Reply-To: <m2h9whij5f.fsf@linux-m68k.org> (Andreas Schwab's message of	"Sat, 27 Dec 2014 09:36:28 +0100")

On Saturday, December 27 2014, Andreas Schwab wrote:

> Sergio Durigan Junior <sergiodj@redhat.com> writes:
>
>> +	{
>> +	  fprintf (stderr, "input_interrupt, count = %d c = %d ", cc, c);
>> +	  if (isprint (c))
>> +	    fprintf (stderr, "('%c')\n", c);
>> +	  else
>> +	    fprintf (stderr, "('\\x%02x)\n", c & 0xFF);
>                                        ^
>
> Missing second quote character.

Ops, thanks.  Corrected version below.

-- 
Sergio
GPG key ID: 0x65FC5E36
Please send encrypted e-mail if possible
http://sergiodj.net/

diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 373fc15..5ff14f9 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -23,6 +23,7 @@
 #include "tdesc.h"
 #include "dll.h"
 #include "rsp-low.h"
+#include <ctype.h>
 #if HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
 #endif
@@ -741,10 +742,18 @@ input_interrupt (int unused)
 
       cc = read_prim (&c, 1);
 
-      if (cc != 1 || c != '\003' || current_thread == NULL)
+      if (cc == 0)
 	{
-	  fprintf (stderr, "input_interrupt, count = %d c = %d ('%c')\n",
-		   cc, c, c);
+	  fprintf (stderr, "client connection closed\n");
+	  return;
+	}
+      else if (cc != 1 || c != '\003' || current_thread == NULL)
+	{
+	  fprintf (stderr, "input_interrupt, count = %d c = %d ", cc, c);
+	  if (isprint (c))
+	    fprintf (stderr, "('%c')\n", c);
+	  else
+	    fprintf (stderr, "('\\x%02x')\n", c & 0xFF);
 	  return;
 	}
 

  reply	other threads:[~2014-12-28  3:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-27  5:24 Sergio Durigan Junior
2014-12-27  8:36 ` Andreas Schwab
2014-12-28  3:01   ` Sergio Durigan Junior [this message]
2014-12-29 11:12     ` Pedro Alves
2014-12-29 19:25       ` Sergio Durigan Junior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lhlslbqg.fsf@redhat.com \
    --to=sergiodj@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).