This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: [PATCH] libdwfl: Correct off-by-one check in segment.c insert.
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Fri, 17 Apr 2015 14:05:33 +0200
- Subject: Re: [PATCH] libdwfl: Correct off-by-one check in segment.c insert.
On Mon, 2015-04-13 at 09:55 +0200, Mark Wielaard wrote:
> On Tue, 2015-04-07 at 18:34 +0200, Mark Wielaard wrote:
> > On Mon, 2015-04-06 at 12:45 -0700, Roland McGrath wrote:
> > > Usually "x + 1 >= y" should be "x > y", no?
> >
> > Do you mean x >= y - 1?
> >
> > The check is for whether there is a next element (x + 1) in the array
> > (size y). If not the array will need extending. If there is such an
> > element we check whether it already marks the end.
> >
> > The bug was accessing that array element if it didn't exist to see
> > whether we needed a new end marker. I am writing that as i + 1 >=
> > dwfl->lookup_elts because if that is not true we'll access
> > dwfl->lookup_addr[i + 1]. So the i + 1 check looks symmetric.
> >
> > Or am I missing something?
>
> I like to push this, because I believe it is correct and the current
> code is wrong. But I don't know whether I am missing something. Please
> let me know if you still think there is something obviously wrong with
> the fix.
For now I have pushed this fix to master since the original code is
wrong and I believe the fix is the clearest way I could write it. But
please let me know if I missed something.
Thanks,
Mark