diff options
| author | Mark Wielaard <[email protected]> | 2015-12-19 01:29:54 +0100 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2016-01-06 14:27:10 +0100 |
| commit | 272018bba1f253bae00b5ba280ad0e0f18c04006 (patch) | |
| tree | f0b20b43f9caf6d193ae9c05f5583699f34bc59d /libelf/elf32_updatenull.c | |
| parent | b7105b40ccd73a8e6b7fce6c11d2088eb1298b33 (diff) | |
libelf: Add elf_compress and elf_compress_gnu.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libelf/elf32_updatenull.c')
| -rw-r--r-- | libelf/elf32_updatenull.c | 23 |
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; + } } } |
