Normally the xlate functions transform an integer number of records.
This isn't the case for Elf Notes or Chdrs. Those start with some
fixed length fields, but also have extra payload. We already made sure
to not check for a multiple of Nhdr recsize, also accept variable Chdr
records. The actual xlate function does handle the header and the
extra payload already.
* elf32_xlatetom.c (xlatetom): Do not check for integer number
of records for ELF_T_CHDR.
* elf32_xlatetof.c (xlatetof): Likewise.
Signed-off-by: Mark Wielaard <[email protected]>
---
libelf/elf32_xlatetof.c | 6 ++++--
libelf/elf32_xlatetom.c | 6 ++++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/libelf/elf32_xlatetof.c b/libelf/elf32_xlatetof.c
index 2c3e9e0ba1b3..d2556e664182 100644
--- a/libelf/elf32_xlatetof.c
+++ b/libelf/elf32_xlatetof.c
@@ -67,9 +67,11 @@ elfw2(LIBELFBITS, xlatetof) (Elf_Data *dest, const Elf_Data
*src,
size_t recsize = __libelf_type_sizes[ELFW(ELFCLASS,LIBELFBITS) -
1][src->d_type];
/* 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. */
+ notes or compressed section headers. 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_type != ELF_T_CHDR
&& src->d_size % recsize != 0)
{
__libelf_seterrno (ELF_E_INVALID_DATA);
diff --git a/libelf/elf32_xlatetom.c b/libelf/elf32_xlatetom.c
index 799c3be729fd..f6a488b4d2ae 100644
--- a/libelf/elf32_xlatetom.c
+++ b/libelf/elf32_xlatetom.c
@@ -68,9 +68,11 @@ elfw2(LIBELFBITS, xlatetom) (Elf_Data *dest, const Elf_Data
*src,
/* 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. */
+ notes or compressed section headers. 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_type != ELF_T_CHDR
&& src->d_size % recsize != 0)
{
__libelf_seterrno (ELF_E_INVALID_DATA);
--
2.56.1