Skip to content

Commit d27ce37

Browse files
committed
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 <debian.tormod@gmail.com>
1 parent da4346b commit d27ce37

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
@@ -1434,6 +1434,8 @@ def read_data(offs, size):
14341434
)
14351435

14361436
def _read_segments(self, f, segment_header_offs, segment_header_count, shstrndx):
1437+
if segment_header_count == 0:
1438+
return
14371439
f.seek(segment_header_offs)
14381440
len_bytes = segment_header_count * self.LEN_SEG_HEADER
14391441
segment_header = f.read(len_bytes)

0 commit comments

Comments
 (0)