From a78af60eaa02877a74ed5f14938a13f01342b48f Mon Sep 17 00:00:00 2001 From: Peter Cawley Date: Tue, 21 May 2024 18:50:01 +0000 Subject: [PATCH] sstrip: Seek to e_phoff before reading phdrs, as they need not immediately follow the ELF header --- sstrip/sstrip.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sstrip/sstrip.c b/sstrip/sstrip.c index f13ee4f..12f7c6e 100644 --- a/sstrip/sstrip.c +++ b/sstrip/sstrip.c @@ -128,6 +128,8 @@ static int readphdrtable(void) { if (!ehdr.e_phoff || !ehdr.e_phnum) return err("ELF file has no program header table."); + if (fseek(thefile, ehdr.e_phoff, SEEK_SET)) + return err("could not seek to program segment header table in file."); if (!(phdrs = realloc(phdrs, ehdr.e_phnum * sizeof *phdrs))) return err("Out of memory!");