[committed] RISC-V: PR28610, Fix ASAN heap-buffer-overflow error in riscv_update_subset.

Nelson Chu nelson.chu@sifive.com
Mon Nov 22 12:25:16 GMT 2021


On Mon, Nov 22, 2021 at 6:03 PM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Nov 22 2021, Nelson Chu wrote:
>
> > On Mon, Nov 22, 2021 at 5:37 PM Andreas Schwab <schwab@linux-m68k.org> wrote:
> >>
> >> On Nov 22 2021, Nelson Chu wrote:
> >>
> >> > diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
> >> > index b8da40c..73a99b5 100644
> >> > --- a/bfd/elfxx-riscv.c
> >> > +++ b/bfd/elfxx-riscv.c
> >> > @@ -2211,6 +2211,9 @@ riscv_update_subset (riscv_parse_subset_t *rps,
> >> >  {
> >> >    const char *p = str;
> >> >
> >> > +  if (p == NULL)
> >> > +    return false;
> >>
> >> How can that ever happen?
> >
> > If we always use the .option arch, then it won't.  But I'm worried
> > that someday we might want to pass a "const char *" to
> > riscv_update_subset directly, like what the .option rvc did.  But
> > accidentally give a NULL pointer...
>
> What do you mean with "accidentally"?  There are exactly three uses of
> that function, and all of them always pass a non-NULL value.
>
> Andreas.

OK, removing the redundant NULL pointer check looks better.  So
removed and committed.  Thanks for the suggestion, Andreas.

Nelson

>
> --
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
> "And now for something completely different."


More information about the Binutils mailing list