mirror of
https://github.com/espressif/esptool.git
synced 2025-10-19 02:43:00 +08:00
fix(elf2image): Handle ELF files with zero program header counts
The program header table can describe zero or more segments. However,
commit ca16d5f3
introduced checks in _read_segments() that will fail
on a zero number of program header entries.
Simply return early and skip these checks in _read_segments() if
e_phnum is zero.
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
This commit is contained in:
@@ -1434,6 +1434,8 @@ class ELFFile:
|
||||
)
|
||||
|
||||
def _read_segments(self, f, segment_header_offs, segment_header_count, shstrndx):
|
||||
if segment_header_count == 0:
|
||||
return
|
||||
f.seek(segment_header_offs)
|
||||
len_bytes = segment_header_count * self.LEN_SEG_HEADER
|
||||
segment_header = f.read(len_bytes)
|
||||
|
Reference in New Issue
Block a user