dress icon indicating copy to clipboard operation
dress copied to clipboard

Fixing segfault due to realloc

Open invictus-0x90 opened this issue 7 years ago • 2 comments

When operating on binaries with large amounts of symbols (ie statically linked), the expanded_section_hdr ptr was becoming invalid after the call to realloc in increase_file_size. I moved it to a stack variable (bit of a hacky fix I know), and now I am able to write an arbitrary number of symbols into the outfile.

Readelf was also complaining about the symbol information, which is fixed in line 325.

I also added the ability to have a size written to the symbol table as well for each symbol.

invictus-0x90 avatar Jul 20 '17 16:07 invictus-0x90

Looks good. Do you mind factoring out global_sh_info_index into the state struct that way there more than one elf can be used at once?

sciencemanx avatar Aug 02 '17 19:08 sciencemanx

Think the latest commit is what you wanted, I haven't looked at this in a while so sorry if it's not correct. I also added a get_size() function, with an example format in size_example.syms. Note that if no size is set it just defaults to the original behaviour.

invictus-0x90 avatar Aug 08 '17 11:08 invictus-0x90