diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2024-05-05 17:35:48 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2024-05-05 17:35:48 +0200 |
| commit | 3db2362c862f2477e01aedaa027b4286c9b0ca87 (patch) | |
| tree | 4ab45eb7b5ce72ea89e3effa4613653eba693aae /src/elfs/elfparser.c | |
| parent | 99b7ef0c92670a2b3abd1fd83adbe29e481ccc83 (diff) | |
| download | box64-3db2362c862f2477e01aedaa027b4286c9b0ca87.tar.gz box64-3db2362c862f2477e01aedaa027b4286c9b0ca87.zip | |
[ELFLOADER] Small change in the parser (for #1493)
Diffstat (limited to 'src/elfs/elfparser.c')
| -rw-r--r-- | src/elfs/elfparser.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/elfs/elfparser.c b/src/elfs/elfparser.c index 803f7dce..fb6e4637 100644 --- a/src/elfs/elfparser.c +++ b/src/elfs/elfparser.c @@ -129,20 +129,20 @@ elfheader_t* ParseElfHeader(FILE* f, const char* name, int exec) h->numSHEntries = header.e_shnum; h->SHIdx = header.e_shstrndx; h->e_type = header.e_type; - if(header.e_shentsize && header.e_shnum) { - // special cases for nums - if(h->numSHEntries == 0) { - printf_dump(LOG_DEBUG, "Read number of Sections in 1st Section\n"); - // read 1st section header and grab actual number from here - fseeko64(f, header.e_shoff, SEEK_SET); - Elf64_Shdr section; - if(fread(§ion, sizeof(Elf64_Shdr), 1, f)!=1) { - box_free(h); - printf_log(LOG_INFO, "Cannot read Initial Section Header\n"); - return NULL; - } - h->numSHEntries = section.sh_size; + // special cases for nums + if(header.e_shentsize && !h->numSHEntries) { + printf_dump(LOG_DEBUG, "Read number of Sections in 1st Section\n"); + // read 1st section header and grab actual number from here + fseeko64(f, header.e_shoff, SEEK_SET); + Elf64_Shdr section; + if(fread(§ion, sizeof(Elf64_Shdr), 1, f)!=1) { + box_free(h); + printf_log(LOG_INFO, "Cannot read Initial Section Header\n"); + return NULL; } + h->numSHEntries = section.sh_size; + } + if(header.e_shentsize && h->numSHEntries) { // now read all section headers printf_dump(LOG_DEBUG, "Read %zu Section header\n", h->numSHEntries); h->SHEntries = (Elf64_Shdr*)box_calloc(h->numSHEntries, sizeof(Elf64_Shdr)); |