From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12733 invoked by alias); 26 Mar 2010 18:03:07 -0000 Received: (qmail 12348 invoked by uid 22791); 26 Mar 2010 18:03:05 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_SORBS_WEB,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from mtaout20.012.net.il (HELO mtaout20.012.net.il) (80.179.55.166) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 26 Mar 2010 18:02:57 +0000 Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0KZW00K00HXQ2900@a-mtaout20.012.net.il> for gdb-patches@sourceware.org; Fri, 26 Mar 2010 21:02:54 +0300 (IDT) Received: from HOME-C4E4A596F7 ([77.127.176.135]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0KZW00JWUI4TBM40@a-mtaout20.012.net.il>; Fri, 26 Mar 2010 21:02:54 +0300 (IDT) Date: Fri, 26 Mar 2010 18:03:00 -0000 From: Eli Zaretskii Subject: Re: [PATCH] Tracepoint source strings In-reply-to: <4BACF406.7080701@codesourcery.com> To: Stan Shebs Cc: gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <83zl1vezan.fsf@gnu.org> References: <4BABDD35.2000209@codesourcery.com> <83aatvh4pf.fsf@gnu.org> <4BACF406.7080701@codesourcery.com> X-IsSubscribed: yes 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 X-SW-Source: 2010-03/txt/msg00908.txt.bz2 > Date: Fri, 26 Mar 2010 10:51:02 -0700 > From: Stan Shebs > CC: Stan Shebs , gdb-patches@sourceware.org > > Eli Zaretskii wrote: > >> struct breakpoint * > >> create_tracepoint_from_upload (struct uploaded_tp *utp) > >> { > >> ! char *addr_str, small_buf[100]; > >> [...] > >> ! sprintf (small_buf, "*%s", hex_string (utp->addr)); > >> > > > > Tz-tz-tz... Using a constant-size buffer in sprintf without any check > > for overflow? Are you sure that calling the buffer ``small'' will > > magically keep you from trouble? ;-) > > > > Presumably even a hypothetical future 128-bit address won't need more > than 65 chars to print. :-) Yes, and then someone comes up and changes the code to put there something in addition to the address (you already prepend an asterisk to it). But if I'm the only one who is bothered by this, I withdraw my objections. > >> written = fwrite ("\x7fTRACE0\n", 8, 1, fp); > >> ! if (written < 8) > >> perror_with_name (pathname); > >> > >> /* Write descriptive info. */ > >> --- 2468,2474 ---- > >> binary file, plus a hint as what this file is, and a version > >> number in case of future needs. */ > >> written = fwrite ("\x7fTRACE0\n", 8, 1, fp); > >> ! if (written < 1) > >> perror_with_name (pathname); > >> > > > > Why did you change this to accept partial writes? > > > > I was hoping to fix a major brain cramp of mine without anybody noticing > - oh well. :-) The two numeric arguments to fwrite are semi-redundant a > la calloc, and the return result is based on the *second* argument, > which is the number of "items". So you are writing a string as if it were an 8-byte int? Won't that swap bytes on some architectures? And why pretend that a string is a number, anyway? As for the rest, my questions were meant to signal that portions of the description are not clear enough, and could use some more explicit description and/or references to other parts of the manual.