Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Stan Shebs <stan@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Tracepoint source strings
Date: Fri, 26 Mar 2010 18:03:00 -0000	[thread overview]
Message-ID: <83zl1vezan.fsf@gnu.org> (raw)
In-Reply-To: <4BACF406.7080701@codesourcery.com>

> Date: Fri, 26 Mar 2010 10:51:02 -0700
> From: Stan Shebs <stan@codesourcery.com>
> CC: Stan Shebs <stan@codesourcery.com>, 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.


  reply	other threads:[~2010-03-26 18:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-25 22:01 Stan Shebs
2010-03-26  8:24 ` Eli Zaretskii
2010-03-26 17:51   ` Stan Shebs
2010-03-26 18:03     ` Eli Zaretskii [this message]
2010-03-26 18:38       ` Stan Shebs
2010-03-26 20:02         ` Eli Zaretskii
2010-03-30 13:18 ` Pedro Alves

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=83zl1vezan.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=stan@codesourcery.com \
    /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