]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sframe: fix PR libsframe/33051
authorIndu Bhagat <indu.bhagat@oracle.com>
Wed, 4 Jun 2025 06:10:46 +0000 (23:10 -0700)
committerIndu Bhagat <indu.bhagat@oracle.com>
Wed, 4 Jun 2025 06:10:46 +0000 (23:10 -0700)
Fix PR libsframe/Bug 33051 - ASAN: heap-buffer-overflow
../../src/libsframe/sframe.c:1054 in
sframe_get_funcdesc_with_addr_internal

The previous commit 9d2a24349e2 (libsframe: correct binary search for
SFrame FDE) adapted the binary search logic in
sframe_get_funcdesc_with_addr_internal.  Adjusting the upper end of the
search index was missed.

The search must only be done for FDEs starting at index 0 and up until
num_fdes - 1.  Prior logic of searching (before commit 9d2a24349e2) was
a bit different.

libsframe/
* sframe.c: Use the correct high index.

libsframe/sframe.c

index 950a6846f042d0e520761f3f1f6e35d5cb0efd84..d38a61dbd636384d6110046fcc1e7c493b03e060 100644 (file)
@@ -1044,7 +1044,7 @@ sframe_get_funcdesc_with_addr_internal (sframe_decoder_ctx *ctx, int32_t addr,
   /* Do the binary search.  */
   fdp = (sframe_func_desc_entry *) ctx->sfd_funcdesc;
   low = 0;
-  high = dhp->sfh_num_fdes;
+  high = dhp->sfh_num_fdes - 1;
   while (low <= high)
     {
       int mid = low + (high - low) / 2;