]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
elf*_xlatetof: do not check ELF_T_NHDR[8] has integer number of records
authorMark Wielaard <mark@klomp.org>
Wed, 28 Aug 2024 21:43:02 +0000 (23:43 +0200)
committerMark Wielaard <mark@klomp.org>
Wed, 11 Sep 2024 15:02:45 +0000 (17:02 +0200)
commit bc0f7450c "elf*_xlatetom: do not check ELF_T_NHDR has integer
number of records" fixed
https://bugzilla.redhat.com/show_bug.cgi?id=835877
But only for xlatetom. Do the same for xlatetof.

       * elf32_xlatetof.c (elfw2(LIBELFBITS, xlatetof)): Do not check for
       integer number of records in case of ELF_T_NHDR[8].

Signed-off-by: Mark Wielaard <mark@klomp.org>
libelf/elf32_xlatetof.c

index ab857409329a3524141165a6e96a30c58bef8b2e..ab3e609ee5d26322eb1948947a8e58d0b6b6fe4a 100644 (file)
@@ -51,7 +51,11 @@ elfw2(LIBELFBITS, xlatetof) (Elf_Data *dest, const Elf_Data *src,
      data types are identical.  */
   size_t recsize = __libelf_type_sizes[ELFW(ELFCLASS,LIBELFBITS) - 1][src->d_type];
 
-  if (src->d_size % recsize != 0)
+  /* We shouldn't require integer number of records when processing
+     notes.  Payload bytes follow the header immediately, it's not an
+     array of records as is the case otherwise.  */
+  if (src->d_type != ELF_T_NHDR && src->d_type != ELF_T_NHDR8
+      && src->d_size % recsize != 0)
     {
       __libelf_seterrno (ELF_E_INVALID_DATA);
       return NULL;