elf*_xlatetof: do not check ELF_T_NHDR[8] has integer number of records
Commit Message
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 | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
Comments
Hi,
On Wed, 2024-08-28 at 23:43 +0200, Mark Wielaard wrote:
> 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].
Pushed this to main.
Cheers,
Mark
@@ -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;