Closed seviezhou closed 4 years ago
Ubuntu X64, gcc (Ubuntu 5.5.0-12ubuntu1), heif (latest master 2fc78e)
cmake ../srcs -DCMAKE_CXX_FLAGS="-fsanitize=address -g" -DCMAKE_C_FLAGS="-fsanitize=address -g" -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address"
modify example.cpp, use example7() to receive filename from command-line.
./build/bin/example @@
================================================================= ==13301==ERROR: AddressSanitizer: global-buffer-overflow on address 0x0000009536e0 at pc 0x0000008203ca bp 0x7ffc75603000 sp 0x7ffc75602ff8 READ of size 2 at 0x0000009536e0 thread T0 #0 0x8203c9 in HevcDecoderConfigurationRecord::getPicHeight() const /home/seviezhou/heif/srcs/common/hevcdecoderconfigrecord.cpp:317:38 #1 0x8826dd in HEIF::WriterImpl::getConfigIndex(HEIF::DecoderConfigId, unsigned short&) /home/seviezhou/heif/srcs/writer/writermetaimpl.cpp:1199:98 #2 0x87e1bf in HEIF::WriterImpl::addImage(HEIF::MediaDataId const&, HEIF::ImageId&) /home/seviezhou/heif/srcs/writer/writermetaimpl.cpp:199:31 #3 0x52072f in main /home/seviezhou/heif/srcs/examples/example.cpp:104:29 #4 0x7f3f5488883f in __libc_start_main /build/glibc-e6zv40/glibc-2.23/csu/../csu/libc-start.c:291 #5 0x41f0b8 in _start (/home/seviezhou/heif/build/bin/example+0x41f0b8) 0x0000009536e0 is located 32 bytes to the left of global variable '<string literal>' defined in '/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_vector.h:960:29' (0x953700) of size 74 '<string literal>' is ascii string 'vector::_M_range_check: __n (which is %zu) >= this->size() (which is %zu)' 0x0000009536e0 is located 31 bytes to the right of global variable 'typeinfo name for HevcDecoderConfigurationRecord' defined in '/home/seviezhou/heif/srcs/common/hevcdecoderconfigrecord.cpp' (0x9536a0) of size 33 'typeinfo name for HevcDecoderConfigurationRecord' is ascii string '30HevcDecoderConfigurationRecord' SUMMARY: AddressSanitizer: global-buffer-overflow /home/seviezhou/heif/srcs/common/hevcdecoderconfigrecord.cpp:317:38 in HevcDecoderConfigurationRecord::getPicHeight() const Shadow bytes around the buggy address: 0x000080122680: 00 00 00 00 00 00 00 00 00 00 00 00 00 07 f9 f9 0x000080122690: f9 f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00 0x0000801226a0: 00 00 00 00 00 00 07 f9 f9 f9 f9 f9 00 00 00 00 0x0000801226b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0000801226c0: 00 00 00 00 00 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 =>0x0000801226d0: f9 f9 f9 f9 00 00 00 00 01 f9 f9 f9[f9]f9 f9 f9 0x0000801226e0: 00 00 00 00 00 00 00 00 00 02 f9 f9 f9 f9 f9 f9 0x0000801226f0: 00 00 00 00 00 00 00 00 00 00 f9 f9 f9 f9 f9 f9 0x000080122700: 00 00 00 02 f9 f9 f9 f9 00 00 00 f9 f9 f9 f9 f9 0x000080122710: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x000080122720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==13301==ABORTING
global-overflow-getPicWidth-hevcdecoderconfigrecord-317.zip
Thank you for reporting this. The issue was fixed in commit b26a7086cb3eba61872f44c7902c54417f1084d5.
System info
Ubuntu X64, gcc (Ubuntu 5.5.0-12ubuntu1), heif (latest master 2fc78e)
Configure
cmake ../srcs -DCMAKE_CXX_FLAGS="-fsanitize=address -g" -DCMAKE_C_FLAGS="-fsanitize=address -g" -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address"
Command line
modify example.cpp, use example7() to receive filename from command-line.
./build/bin/example @@
AddressSanitizer output
POC
global-overflow-getPicWidth-hevcdecoderconfigrecord-317.zip