summaryrefslogtreecommitdiffstats
path: root/libelf/elf_begin.c
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2017-10-04 20:52:53 +0200
committerMark Wielaard <[email protected]>2017-10-13 16:22:06 +0200
commit4f977868eab2ea196a44e9d96c9e777134411391 (patch)
treebfb2f56a6f36d03e492c2063a2ab66321579f8ca /libelf/elf_begin.c
parentfef9e11b308465ee83e9559e5e545b9b13da2df2 (diff)
libelf: Don't error out when sanity checking e_shoff if scncnt is zero.
We won't use the e_shoff value in that case because we will set elf->state.elf[64|32].scns.cnt to zero to indicate not to read any section header data from the file. Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libelf/elf_begin.c')
-rw-r--r--libelf/elf_begin.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index 55452783..fb3a5b57 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -373,7 +373,7 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
|| (((uintptr_t) ((char *) ehdr + e_shoff)
& (__alignof__ (Elf32_Shdr) - 1)) == 0)))
{
- if (unlikely (e_shoff >= maxsize)
+ if (unlikely (scncnt > 0 && e_shoff >= maxsize)
|| unlikely (maxsize - e_shoff
< scncnt * sizeof (Elf32_Shdr)))
{
@@ -475,7 +475,7 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
|| (((uintptr_t) ((char *) ehdr + e_shoff)
& (__alignof__ (Elf64_Shdr) - 1)) == 0)))
{
- if (unlikely (e_shoff >= maxsize)
+ if (unlikely (scncnt > 0 && e_shoff >= maxsize)
|| unlikely (maxsize - e_shoff
< scncnt * sizeof (Elf64_Shdr)))
goto free_and_out;