Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/patchelf
base: 47dc18d0e5c1
Choose a base ref
...
head repository: NixOS/patchelf
compare: 57ad111ab4c5
Choose a head ref
  • 15 commits
  • 9 files changed
  • 2 contributors

Commits on Nov 15, 2020

  1. Add ELF test case with invalid string table index

    Parsing this file results in patchelf triggering an assertion:
    
    patchelf: patchelf.cc:431: ElfFile<Elf64_Ehdr, Elf64_Phdr, Elf64_Shdr, unsigned long, unsigned long, Elf64_Dyn, Elf64_Sym, Elf64_Verneed, unsigned short>::ElfFile(FileContents) [Elf_Ehdr = Elf64_Ehdr, Elf_Phdr = Elf64_Phdr, Elf_Shdr = Elf64_Shdr, Elf_Addr = unsigned long, Elf_Off = unsigned long, Elf_Dyn = Elf64_Dyn, Elf_Sym = Elf64_Sym, Elf_Verneed = Elf64_Verneed, Elf_Versym = unsigned short]: Assertion `shstrtabIndex < shdrs.size()' failed.
    Program received signal SIGABRT, Aborted.
    blitz committed Nov 15, 2020
    Copy the full SHA
    1457195 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    b552c30 View commit details
    Browse the repository at this point in the history
  3. Add test case with invalid shrstab size

    Parsing this file results in patchelf triggering an assertion:
    
    patchelf: patchelf.cc:384: void checkPointer(const FileContents &, void *, unsigned int): Assertion `q >= contents->data() && q + size <= contents->data() + contents->size()' failed.
    Aborted (core dumped)
    blitz committed Nov 15, 2020
    Copy the full SHA
    1162de5 View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    a954a08 View commit details
    Browse the repository at this point in the history
  5. Add ELF test case with empty string table

    Parsing this file results in patchelf triggering an assertion:
    
    patchelf: patchelf.cc:439: ElfFile<Elf64_Ehdr, Elf64_Phdr, Elf64_Shdr, unsigned long, unsigned long, Elf64_Dyn, Elf64_Sym, Elf64_Verneed, unsigned short>::ElfFile(FileContents) [Elf_Ehdr = Elf64_Ehdr, Elf_Phdr = Elf64_Phdr, Elf_Shdr = Elf64_Shdr, Elf_Addr = unsigned long, Elf_Off = unsigned long, Elf_Dyn = Elf64_Dyn, Elf_Sym = Elf64_Sym, Elf_Verneed = Elf64_Verneed, Elf_Versym = unsigned short]: Assertion `shstrtabSize > 0' failed.
    Aborted (core dumped)
    blitz committed Nov 15, 2020
    Copy the full SHA
    62e39e0 View commit details
    Browse the repository at this point in the history
  6. Copy the full SHA
    cee8c8c View commit details
    Browse the repository at this point in the history
  7. Add test case with non-terminated string table

    Parsing this file results in patchelf triggering an assertion:
    
    patchelf: patchelf.cc:442: ElfFile<Elf64_Ehdr, Elf64_Phdr, Elf64_Shdr, unsigned long, unsigned long, Elf64_Dyn, Elf64_Sym, Elf64_Verneed, unsigned short>::ElfFile(FileContents) [Elf_Ehdr = Elf64_Ehdr, Elf_Phdr = Elf64_Phdr, Elf_Shdr = Elf64_Shdr, Elf_Addr = unsigned long, Elf_Off = unsigned long, Elf_Dyn = Elf64_Dyn, Elf_Sym = Elf64_Sym, Elf_Verneed = Elf64_Verneed, Elf_Versym = unsigned short]: Assertion `shstrtab[shstrtabSize - 1] == 0' failed.
    Aborted (core dumped)
    blitz committed Nov 15, 2020
    Copy the full SHA
    e57205f View commit details
    Browse the repository at this point in the history
  8. Copy the full SHA
    7a8214c View commit details
    Browse the repository at this point in the history
  9. Add test case with invalid section header sh_name

    Parsing this file results in patchelf segfaulting at:
    
        at /nix/store/h31cy7jm6g7cfqbhc5pm4rf9c53i3qfb-gcc-9.3.0/include/c++/9.3.0/bits/char_traits.h:335
        at /nix/store/h31cy7jm6g7cfqbhc5pm4rf9c53i3qfb-gcc-9.3.0/include/c++/9.3.0/bits/basic_string.h:527
        this=0x7fffffff8028, fileContents=...) at patchelf.cc:449
    blitz committed Nov 15, 2020
    Copy the full SHA
    de9fa4d View commit details
    Browse the repository at this point in the history
  10. Add bounds checking for invalid section header name offsets

    ... otherwise strlen() (in the std::string constructor) will be called
    with an out-of-bounds pointer.
    blitz committed Nov 15, 2020
    Copy the full SHA
    fa8896a View commit details
    Browse the repository at this point in the history
  11. Add test case with invalid phdr offset

    Parsing this file results in patchelf segfaulting at:
    
    Program received signal SIGSEGV, Segmentation fault.
    std::vector<Elf32_Phdr, std::allocator<Elf32_Phdr> >::_M_realloc_insert<Elf32_Phdr const&> (this=0x7fffffff80a8, __position=..., __args=...)
        at /nix/store/h31cy7jm6g7cfqbhc5pm4rf9c53i3qfb-gcc-9.3.0/include/c++/9.3.0/bits/vector.tcc:449
    449		  _Alloc_traits::construct(this->_M_impl,
    (gdb) bt
        at /nix/store/h31cy7jm6g7cfqbhc5pm4rf9c53i3qfb-gcc-9.3.0/include/c++/9.3.0/bits/vector.tcc:449
        at /nix/store/h31cy7jm6g7cfqbhc5pm4rf9c53i3qfb-gcc-9.3.0/include/c++/9.3.0/bits/stl_vector.h:1195
        this=0x7fffffff8088, fileContents=...) at patchelf.cc:421
    blitz committed Nov 15, 2020
    Copy the full SHA
    c105b1c View commit details
    Browse the repository at this point in the history
  12. Copy the full SHA
    52e9dd5 View commit details
    Browse the repository at this point in the history
  13. Fix endian issue when creating sectionsByOldIndex

    sectionsByOldIndex was resized to hdr->e_shnum instead of
    rdi(hdr->e_shnum). This omitted the endianness conversion and probably
    only worked by accident, because the 16-bit LE->BE conversion results
    in integers that are larger as long as there no more than 255 section
    headers.
    
    This would be a good usecase for std::transform, but I'm unsure
    whether we want to bump requirements to build patchelf to C++ 2017.
    blitz committed Nov 15, 2020
    Copy the full SHA
    d148bae View commit details
    Browse the repository at this point in the history
  14. Gracefully handle ELF files with out-of-bounds shdr offsets

    This is similar to the earlier fix for phdr offsets, but the fuzzer
    didn't find this.
    blitz committed Nov 15, 2020
    Copy the full SHA
    883fdf9 View commit details
    Browse the repository at this point in the history

Commits on Nov 16, 2020

  1. Merge pull request #251 from blitz/fuzzing-fixes

    Fuzzing fixes
    edolstra committed Nov 16, 2020
    Copy the full SHA
    57ad111 View commit details
    Browse the repository at this point in the history