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 <[email protected]>
---
libelf/elf32_xlatetof.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libelf/elf32_xlatetof.c b/libelf/elf32_xlatetof.c
index ab857409329a..ab3e609ee5d2 100644
--- a/libelf/elf32_xlatetof.c
+++ b/libelf/elf32_xlatetof.c
@@ -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;
--
2.46.0