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

A global-buffer-overflow in hevcdecoderconfigrecord.cpp:317:38 #87

Closed
seviezhou opened this issue Aug 4, 2020 · 1 comment
Closed

Comments

@seviezhou
Copy link

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

=================================================================
==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

POC

global-overflow-getPicWidth-hevcdecoderconfigrecord-317.zip

@lassehe
Copy link
Collaborator

lassehe commented Aug 12, 2020

Thank you for reporting this. The issue was fixed in commit b26a708.

@lassehe lassehe closed this as completed Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants