From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27616 invoked by alias); 18 Jul 2006 12:34:44 -0000 Received: (qmail 27599 invoked by uid 22791); 18 Jul 2006 12:34:43 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Tue, 18 Jul 2006 12:34:41 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1G2oma-0003qH-OV; Tue, 18 Jul 2006 08:34:36 -0400 Date: Tue, 18 Jul 2006 12:34:00 -0000 From: Daniel Jacobowitz To: Mark Kettenis Cc: Vladimir Prus , gdb-patches@sources.redhat.com Subject: Re: [PATCH] zero-terminate result of target_read_alloc Message-ID: <20060718123436.GB14653@nevyn.them.org> Mail-Followup-To: Mark Kettenis , Vladimir Prus , gdb-patches@sources.redhat.com References: <200607181356.16071.vladimir@codesourcery.com> <24758.192.87.1.22.1153221922.squirrel@webmail.xs4all.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <24758.192.87.1.22.1153221922.squirrel@webmail.xs4all.nl> User-Agent: Mutt/1.5.11+cvs20060403 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-07/txt/msg00225.txt.bz2 On Tue, Jul 18, 2006 at 01:25:22PM +0200, Mark Kettenis wrote: > > > > This patch makes result of target_read_alloc zero-terminated. > > The point is that often the object is not allowed to contain embedded > > zeros, > > and working with zero-terminated strings is much easier. > > > > OK? > > This is wrong. Either the terminating nul is part of the object you're > reading or it is not. GDB shouldn't at its own. I figured the same but actually reading a couple of objects and managing them convinced me that Volodya's right. Note that he's not adding one to the length returned - if you want binary data, you'll get binary data. It just allows you to easily treat the result as a string if you plan to treat it as a string anyway. As you can probably guess from context, we have these bunches of XML files that we read from the target and then do text processing on. On the branch where I developed the XML bits for the first time, I didn't think to make this change - so the very first thing I had to do with the result of target_read_alloc was to allocate something one byte bigger with a NUL on the end of it! -- Daniel Jacobowitz CodeSourcery