elf: Account for glibc-hwcaps/ prefix in _dl_important_hwcaps

Message ID 87sg7wrayg.fsf@oldenburg2.str.redhat.com
State Committed
Commit 8a30bb4e0604aefcf28f20360fc8ba8ef8604b9c
Headers
Series elf: Account for glibc-hwcaps/ prefix in _dl_important_hwcaps |

Commit Message

Florian Weimer Dec. 23, 2020, 11:57 a.m. UTC
  I tested this on aarch64-linux-gnu, i686-linux-gnu,
powerp64le-linux-gnu, s390x-linux-gnu, x86_64-linux-gnu.  I cannot
reproduce the original crash, though.  I'm quite confident that I have
found the actual problem though, and this change is not just papering
over the buffer size computation by computing a larger (but still wrong)
value.

---
 elf/dl-hwcaps.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Szabolcs Nagy Dec. 23, 2020, 3:24 p.m. UTC | #1
The 12/23/2020 12:57, Florian Weimer wrote:
> I tested this on aarch64-linux-gnu, i686-linux-gnu,
> powerp64le-linux-gnu, s390x-linux-gnu, x86_64-linux-gnu.  I cannot
> reproduce the original crash, though.  I'm quite confident that I have
> found the actual problem though, and this change is not just papering
> over the buffer size computation by computing a larger (but still wrong)
> value.

it fixes the crash i was seeing. thanks

it looks good to me.

> 
> ---
>  elf/dl-hwcaps.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/elf/dl-hwcaps.c b/elf/dl-hwcaps.c
> index 000e3c0eb9..6c394714d8 100644
> --- a/elf/dl-hwcaps.c
> +++ b/elf/dl-hwcaps.c
> @@ -192,6 +192,7 @@ _dl_important_hwcaps (const char *glibc_hwcaps_prepend,
>  
>    /* Each hwcaps subdirectory has a GLIBC_HWCAPS_PREFIX string prefix
>       and a "/" suffix once stored in the result.  */
> +  hwcaps_counts.maximum_length += strlen (GLIBC_HWCAPS_PREFIX) + 1;
>    size_t total = (hwcaps_counts.count * (strlen (GLIBC_HWCAPS_PREFIX) + 1)
>  		  + hwcaps_counts.total_length);
>  
> 
> -- 
> Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
> Commercial register: Amtsgericht Muenchen, HRB 153243,
> Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill
>
  

Patch

diff --git a/elf/dl-hwcaps.c b/elf/dl-hwcaps.c
index 000e3c0eb9..6c394714d8 100644
--- a/elf/dl-hwcaps.c
+++ b/elf/dl-hwcaps.c
@@ -192,6 +192,7 @@  _dl_important_hwcaps (const char *glibc_hwcaps_prepend,
 
   /* Each hwcaps subdirectory has a GLIBC_HWCAPS_PREFIX string prefix
      and a "/" suffix once stored in the result.  */
+  hwcaps_counts.maximum_length += strlen (GLIBC_HWCAPS_PREFIX) + 1;
   size_t total = (hwcaps_counts.count * (strlen (GLIBC_HWCAPS_PREFIX) + 1)
 		  + hwcaps_counts.total_length);