Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Philippe Waroquiers <philippe.waroquiers@skynet.be>,
	Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFAv2] Fix buffer overflow regression due to minsym malloc-ed instead of obstack-ed.
Date: Tue, 26 Mar 2019 18:46:00 -0000	[thread overview]
Message-ID: <69c0a306-5829-54c4-d2a6-1b29be829100@simark.ca> (raw)
In-Reply-To: <1553543645.1504.7.camel@skynet.be>

On 2019-03-25 3:54 p.m., Philippe Waroquiers wrote:
> On Mon, 2019-03-25 at 09:31 -0600, Tom Tromey wrote:
>> Philippe> +  int n_after_msymbol = minsym.objfile->per_bfd->minimal_symbol_count
>> Philippe> +    - (msymbol - minsym.objfile->per_bfd->msymbols.get ())
>> Philippe> +    - 1;
>>
>> What do you think of the appended instead?
>> The idea is to make the last element more explicit.
> Yes, that looks better, 2 minor comments below.

I just wanted to mention that I just hit this bug, and that Tom's patch fixes it for me.

>> @@ -1499,21 +1498,24 @@ minimal_symbol_upper_bound (struct bound_minimal_symbol minsym)
>>       other sections, to find the next symbol in this section with a
>>       different address.  */
>>  
>> +  struct minimal_symbol *last
>> +    = (minsym.objfile->per_bfd->msymbols.get ()
>> +       + minsym.objfile->per_bfd->minimal_symbol_count);
> Are the parenthesis needed here ?

It is mentioned here, search for "extra paren":

https://www.gnu.org/prep/standards/html_node/Formatting.html#Formatting

It's just there to please people who use Emacs :).

> Also, I find the name 'last' a little bit confusing,
> as in the loop below, last is not handled.
> Maybe last could be the 'real' last i.e. as:
>    minsym.objfile->per_bfd->msymbols.get () +       
>     + minsym.objfile->per_bfd->minimal_symbol_count - 1;
> 
> and have the '< last' conditions below then be '<= last'.
> 
> That makes more clear for me that we handle the last
> element of the array.

This, or name the variable "past_the_end" or something like that.

Simon


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

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-24  9:19 Philippe Waroquiers
2019-03-25 15:31 ` Tom Tromey
2019-03-25 19:54   ` Philippe Waroquiers
2019-03-26 18:46     ` Simon Marchi [this message]
2019-03-26 19:20       ` Tom Tromey

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=69c0a306-5829-54c4-d2a6-1b29be829100@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=philippe.waroquiers@skynet.be \
    --cc=tom@tromey.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