From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1494 invoked by alias); 20 Jan 2014 19:23:45 -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 1368 invoked by uid 89); 20 Jan 2014 19:23:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS 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 ESMTP; Mon, 20 Jan 2014 19:23:43 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0KJIQ0f002992 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 20 Jan 2014 14:18:26 -0500 Received: from barimba.redhat.com (ovpn-113-85.phx2.redhat.com [10.3.113.85]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0KJINCu031799; Mon, 20 Jan 2014 14:18:25 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFC 4/9] don't let hexify call strlen Date: Mon, 20 Jan 2014 19:23:00 -0000 Message-Id: <1390245501-1186-5-git-send-email-tromey@redhat.com> In-Reply-To: <1390245501-1186-1-git-send-email-tromey@redhat.com> References: <1390245501-1186-1-git-send-email-tromey@redhat.com> X-SW-Source: 2014-01/txt/msg00753.txt.bz2 hexify had the same issue as bin2hex; and the fix is the same. 2014-01-20 Tom Tromey * common/rsp-low.c (hexify): Never take strlen of argument. 2014-01-20 Tom Tromey * remote-utils.c (monitor_output): Pass explicit length to hexify. --- gdb/ChangeLog | 4 ++++ gdb/common/rsp-low.c | 4 ---- gdb/gdbserver/ChangeLog | 5 +++++ gdb/gdbserver/remote-utils.c | 5 +++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gdb/common/rsp-low.c b/gdb/common/rsp-low.c index 9c5119b..feb6d0c 100644 --- a/gdb/common/rsp-low.c +++ b/gdb/common/rsp-low.c @@ -177,10 +177,6 @@ hexify (char *hex, const char *bin, int count) { int i; - /* May use a length, or a nul-terminated string as input. */ - if (count == 0) - count = strlen (bin); - for (i = 0; i < count; i++) { *hex++ = tohex ((*bin >> 4) & 0xf); diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c index 710d398..b2a84c3 100644 --- a/gdb/gdbserver/remote-utils.c +++ b/gdb/gdbserver/remote-utils.c @@ -1558,10 +1558,11 @@ relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc) void monitor_output (const char *msg) { - char *buf = xmalloc (strlen (msg) * 2 + 2); + int len = strlen (msg); + char *buf = xmalloc (len * 2 + 2); buf[0] = 'O'; - hexify (buf + 1, msg, 0); + hexify (buf + 1, msg, len); putpkt (buf); free (buf); -- 1.8.1.4