summaryrefslogtreecommitdiffstats
path: root/libelf/elf32_updatenull.c
diff options
context:
space:
mode:
Diffstat (limited to 'libelf/elf32_updatenull.c')
-rw-r--r--libelf/elf32_updatenull.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c
index d3754d32..03de0321 100644
--- a/libelf/elf32_updatenull.c
+++ b/libelf/elf32_updatenull.c
@@ -382,12 +382,27 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum)
/* Check that the section size is actually a multiple of
the entry size. */
- if (shdr->sh_entsize != 0
- && unlikely (shdr->sh_size % shdr->sh_entsize != 0)
+ if (shdr->sh_entsize != 0 && shdr->sh_entsize != 1
&& (elf->flags & ELF_F_PERMISSIVE) == 0)
{
- __libelf_seterrno (ELF_E_INVALID_SHENTSIZE);
- return -1;
+ /* For compressed sections check the uncompressed size. */
+ ElfW2(LIBELFBITS,Word) sh_size;
+ if ((shdr->sh_flags & SHF_COMPRESSED) == 0)
+ sh_size = shdr->sh_size;
+ else
+ {
+ ElfW2(LIBELFBITS,Chdr) *chdr;
+ chdr = elfw2(LIBELFBITS,getchdr) (scn);
+ if (unlikely (chdr == NULL))
+ return -1;
+ sh_size = chdr->ch_size;
+ }
+
+ if (unlikely (sh_size % shdr->sh_entsize != 0))
+ {
+ __libelf_seterrno (ELF_E_INVALID_SHENTSIZE);
+ return -1;
+ }
}
}