Projects STRLCPY LIEF Commits 129e542a
🤬
  • ■ ■ ■ ■ ■
    src/ELF/Binary.cpp
    skipped 1728 lines
    1729 1729   span<const uint8_t> content = segment->content();
    1730 1730   const uint64_t offset = virtual_address - segment->virtual_address();
    1731 1731   uint64_t checked_size = size;
     1732 + 
     1733 + if (offset >= content.size()) {
     1734 + return {};
     1735 + }
     1736 + 
    1732 1737   if ((offset + checked_size) > content.size()) {
    1733 1738   checked_size = checked_size - (offset + checked_size - content.size());
    1734 1739   }
    skipped 1557 lines
  • ■ ■ ■ ■ ■ ■
    tests/elf/test_issues.py
    skipped 23 lines
    24 24   sym: lief.ELF.Symbol = elf.get_symbol("strstr")
    25 25   assert sym.imported
    26 26   
     27 +def test_issue_1023():
     28 + """
     29 + Make sure that get_content_from_virtual_address return an empty
     30 + buffer when trying to read bss segment
     31 + """
     32 + elf = lief.ELF.parse(get_sample('ELF/nopie_bss_671.elf'))
     33 + 
     34 + bss_segment = elf.segments[3]
     35 + bss_start = bss_segment.virtual_address + bss_segment.physical_size
     36 + bss_content = elf.get_content_from_virtual_address(bss_start + 1, 1)
     37 + 
     38 + assert len(bss_content) == 0
     39 + 
Please wait...
Page is in error, reload to recover