aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/target/image.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/target/image.c b/src/target/image.c
index 9608375..8f72329 100644
--- a/src/target/image.c
+++ b/src/target/image.c
@@ -426,7 +426,10 @@ static int image_elf32_read_headers(struct image *image)
(field32(elf, elf->segments32[i].p_filesz) != 0))
image->num_sections++;
- assert(image->num_sections > 0);
+ if (image->num_sections == 0) {
+ LOG_ERROR("invalid ELF file, no loadable segments");
+ return ERROR_IMAGE_FORMAT_ERROR;
+ }
/**
* some ELF linkers produce binaries with *all* the program header
@@ -548,7 +551,10 @@ static int image_elf64_read_headers(struct image *image)
(field64(elf, elf->segments64[i].p_filesz) != 0))
image->num_sections++;
- assert(image->num_sections > 0);
+ if (image->num_sections == 0) {
+ LOG_ERROR("invalid ELF file, no loadable segments");
+ return ERROR_IMAGE_FORMAT_ERROR;
+ }
/**
* some ELF linkers produce binaries with *all* the program header