From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21960 invoked by alias); 28 Dec 2014 03:01:41 -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 21812 invoked by uid 89); 28 Dec 2014 03:00:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sun, 28 Dec 2014 03:00:51 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBS30f4w005993 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 27 Dec 2014 22:00:42 -0500 Received: from localhost (dhcp-10-15-16-169.yyz.redhat.com [10.15.16.169]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sBS30e2i005765 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Sat, 27 Dec 2014 22:00:40 -0500 From: Sergio Durigan Junior To: Andreas Schwab Cc: GDB Patches , Pedro Alves Subject: Re: [PATCH] Sanitize input_interrupt output References: <1419657863-13470-1-git-send-email-sergiodj@redhat.com> X-URL: http://blog.sergiodj.net Date: Sun, 28 Dec 2014 03:01:00 -0000 In-Reply-To: (Andreas Schwab's message of "Sat, 27 Dec 2014 09:36:28 +0100") Message-ID: <87lhlslbqg.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-12/txt/msg00647.txt.bz2 On Saturday, December 27 2014, Andreas Schwab wrote: > Sergio Durigan Junior 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 #if HAVE_SYS_IOCTL_H #include #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; }