Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fileinfo crashes in ElfImage::addSegment(): uncaught exception retdec::utils::InvalidRangeException #240

Closed
bansan85 opened this issue Mar 5, 2018 · 2 comments

Comments

@bansan85
Copy link

bansan85 commented Mar 5, 2018

fileinfo crashes in ElfImage::addSegment

Maybe related to #239

Input

fileinfo FILE
addSegment.zip

Output

Backtrace:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff5c6fc5f in __GI_abort () at abort.c:90
#2  0x00007ffff66104d5 in __gnu_cxx::__verbose_terminate_handler () at /home/legarrec/info/portage/sys-devel/gcc-7.3.0/work/gcc-7.3.0/libstdc++-v3/libsupc++/vterminate.cc:95
#3  0x00007ffff660df26 in __cxxabiv1::__terminate (handler=<optimized out>) at /home/legarrec/info/portage/sys-devel/gcc-7.3.0/work/gcc-7.3.0/libstdc++-v3/libsupc++/eh_terminate.cc:47
#4  0x00007ffff660df81 in std::terminate () at /home/legarrec/info/portage/sys-devel/gcc-7.3.0/work/gcc-7.3.0/libstdc++-v3/libsupc++/eh_terminate.cc:57
#5  0x00007ffff660e20d in __cxxabiv1::__cxa_throw (obj=<optimized out>, tinfo=tinfo@entry=0x555557006a18 <typeinfo for retdec::utils::InvalidRangeException>, dest=dest@entry=0x5555559e30c0 <retdec::utils::InvalidRangeException::~InvalidRangeException()>)
    at /home/legarrec/info/portage/sys-devel/gcc-7.3.0/work/gcc-7.3.0/libstdc++-v3/libsupc++/eh_throw.cc:93
#6  0x00005555559e327a in retdec::utils::Range<unsigned long>::Range (this=<optimized out>, start=<optimized out>, end=<optimized out>) at /home/legarrec/info/programmation/retdec/include/retdec/utils/range.h:55
#7  0x0000555555a26925 in retdec::loader::ElfImage::addSegment (this=this@entry=0x555557048b40, secSeg=secSeg@entry=0x555557049070, address=address@entry=3472328296227680304, memSize=18388250262078763056) at /home/legarrec/info/programmation/retdec/src/loader/loader/elf/elf_image.cpp:314
#8  0x0000555555a361d1 in retdec::loader::ElfImage::loadExecutableFile (this=this@entry=0x555557048b40) at /home/legarrec/info/programmation/retdec/src/loader/loader/elf/elf_image.cpp:97
#9  0x0000555555a36a78 in retdec::loader::ElfImage::load (this=0x555557048b40) at /home/legarrec/info/programmation/retdec/src/loader/loader/elf/elf_image.cpp:50
#10 0x00005555559da34a in retdec::loader::(anonymous namespace)::createImageImpl (fileFormat=std::shared_ptr (count 3, weak 0) 0x555557047f90) at /home/legarrec/info/programmation/retdec/src/loader/image_factory.cpp:52
#11 retdec::loader::createImage (fileFormat=std::shared_ptr (count 3, weak 0) 0x555557047f90) at /home/legarrec/info/programmation/retdec/src/loader/image_factory.cpp:88
#12 0x000055555563ce3e in fileinfo::FileDetector::getLoaderInfo (this=this@entry=0x555557047bc0) at /home/legarrec/info/programmation/retdec/src/fileinfo/file_detector/file_detector.cpp:250
#13 0x00005555556402c4 in fileinfo::FileDetector::getAllInformation (this=0x555557047bc0) at /home/legarrec/info/programmation/retdec/src/fileinfo/file_detector/file_detector.cpp:334
#14 0x00005555555db614 in main (argc=<optimized out>, argv=<optimized out>) at /home/legarrec/info/programmation/retdec/src/fileinfo/fileinfo.cpp:419

From master (63f1a3de)

@s3rvac
Copy link
Member

s3rvac commented Mar 6, 2018

Thank you for the report. I can confirm that fileinfo crashes due to an uncaught exception:

$ retdec-fileinfo addSegment
terminate called after throwing an instance of 'retdec::utils::InvalidRangeException'
  what():  Invalid Range: end is greater than start
Aborted

This is the same error as in #239, but as the backtrace slightly differs, I will keep the issue open.

@s3rvac s3rvac changed the title fileinfo crashes in ElfImage::addSegment fileinfo crashes in ElfImage::addSegment(): uncaught exception retdec::utils::InvalidRangeException Mar 6, 2018
@mbandzi mbandzi self-assigned this Mar 13, 2018
@mbandzi
Copy link
Contributor

mbandzi commented Mar 14, 2018

Fixed in 8dc010c. Invalid values caused integer overflow that leads to invalid range. If this is encountered, a nullptr is returned and further processing stopped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants