Skip to content

Commit 2e87882

Browse files
tormodvoldenDzarda7
authored andcommitted
fix(elf2image): Handle ELF files with zero program header counts
The program header table can describe zero or more segments. However, commit ca16d5f 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 <[email protected]>
1 parent 13121d4 commit 2e87882

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

esptool/bin_image.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,8 @@ def read_data(offs, size):
14181418
)
14191419

14201420
def _read_segments(self, f, segment_header_offs, segment_header_count, shstrndx):
1421+
if segment_header_count == 0:
1422+
return
14211423
f.seek(segment_header_offs)
14221424
len_bytes = segment_header_count * self.LEN_SEG_HEADER
14231425
segment_header = f.read(len_bytes)

0 commit comments

Comments
 (0)