[PATCH] libdwfl: Correct off-by-one check in segment.c insert.

Mark Wielaard mjw at redhat.com
Mon Apr 13 07:55:03 UTC 2015


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.

Thanks,

Mark
-------------- next part --------------
An embedded message was scrubbed...
From: Mark Wielaard <mjw at redhat.com>
Subject: [PATCH] libdwfl: Correct off-by-one check in segment.c insert.
Date: Thu,  2 Apr 2015 13:39:03 +0200
Size: 3244
URL: <https://lists.fedorahosted.org/pipermail/elfutils-devel/attachments/20150413/943a5986/attachment.mht>


More information about the elfutils-devel mailing list