[FFmpeg-trac] #8860(avcodec:new): A stack-buffer-overflow in aacdec_template.c:539:24

FFmpeg trac at avcodec.org
Sat Aug 22 16:53:50 EEST 2020


#8860: A stack-buffer-overflow in aacdec_template.c:539:24
------------------------------------+-----------------------------------
             Reporter:  seviezhou   |                    Owner:
                 Type:  defect      |                   Status:  new
             Priority:  normal      |                Component:  avcodec
              Version:  git-master  |               Resolution:
             Keywords:  aac         |               Blocked By:
             Blocking:              |  Reproduced by developer:  0
Analyzed by developer:  0           |
------------------------------------+-----------------------------------

Comment (by seviezhou):

 Use `./configure --toolchain=clang-asan && make ffmpeg_g`:

 {{{
 ffmpeg version N-98802-g01a580f141 Copyright (c) 2000-2020 the FFmpeg
 developers
   built with clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
   configuration: --toolchain=clang-asan
   libavutil      56. 58.100 / 56. 58.100
   libavcodec     58.101.100 / 58.101.100
   libavformat    58. 51.100 / 58. 51.100
   libavdevice    58. 11.101 / 58. 11.101
   libavfilter     7. 87.100 /  7. 87.100
   libswscale      5.  8.100 /  5.  8.100
   libswresample   3.  8.100 /  3.  8.100
 [aac @ 0x61b000000080] Format aac detected only with low score of 1,
 misdetection possible!
 [aac @ 0x61b000000080] Packet corrupt (stream = 0, dts = NOPTS).
 [aac @ 0x619000000580] Error decoding AAC frame header.
 [aac @ 0x619000000580] More than one AAC RDB per ADTS frame is not
 implemented. Update your FFmpeg version to the newest one from Git. If the
 problem still occurs, it means that your file has a feature which has not
 been implemented.
 [aac @ 0x619000000580] Multiple frames in a packet.
 [aac @ 0x619000000580] channel element 3.6 is not allocated
 [aac @ 0x61b000000080] decoding for stream 0 failed
 [aac @ 0x61b000000080] Estimating duration from bitrate, this may be
 inaccurate
 [aac @ 0x61b000000080] Could not find codec parameters for stream 0
 (Audio: aac (Main), 4.0, fltp, 198 kb/s): unspecified sample rate
 Consider increasing the value for the 'analyzeduration' (0) and
 'probesize' (5000000) options
 Input #0, aac, from 'stack-overflow-output_configure-aacdec_template-539':
   Duration: 00:00:00.02, bitrate: 198 kb/s
     Stream #0:0: Audio: aac (Main), 4.0, fltp, 198 kb/s
 Stream mapping:
   Stream #0:0 -> #0:0 (aac (native) -> aac (native))
 Press [q] to stop, [?] for help
 [aac @ 0x619000001e80] Error decoding AAC frame header.
 Error while decoding stream #0:0: Error number -50531338 occurred
 [aac @ 0x619000001e80] Gain control is not implemented. Update your FFmpeg
 version to the newest one from Git. If the problem still occurs, it means
 that your file has a feature which has not been implemented.
 [aac @ 0x619000001e80] Sample rate index in program config element does
 not match the sample rate index configured by the container.
 =================================================================
 ==30448==ERROR: AddressSanitizer: stack-buffer-overflow on address
 0x7fffe9040e65 at pc 0x00000294ef91 bp 0x7fffe903fe10 sp 0x7fffe903fe08
 READ of size 1 at 0x7fffe9040e65 thread T0
     #0 0x294ef90 in output_configure
 /home/seviezhou/ffmpeg/libavcodec/aacdec_template.c:539:24
     #1 0x295ee10 in aac_decode_frame_int
 /home/seviezhou/ffmpeg/libavcodec/aacdec_template.c:3312:23
     #2 0x2947523 in aac_decode_frame
 /home/seviezhou/ffmpeg/libavcodec/aacdec_template.c:3457:15
     #3 0x126db5c in decode_simple_internal
 /home/seviezhou/ffmpeg/libavcodec/decode.c:342:15
     #4 0x126db5c in decode_simple_receive_frame
 /home/seviezhou/ffmpeg/libavcodec/decode.c:538
     #5 0x126db5c in decode_receive_frame_internal
 /home/seviezhou/ffmpeg/libavcodec/decode.c:556
     #6 0x126d46d in avcodec_send_packet
 /home/seviezhou/ffmpeg/libavcodec/decode.c:614:15
     #7 0x567e4e in decode /home/seviezhou/ffmpeg/fftools/ffmpeg.c:2217:15
     #8 0x567e4e in decode_audio
 /home/seviezhou/ffmpeg/fftools/ffmpeg.c:2274
     #9 0x567e4e in process_input_packet
 /home/seviezhou/ffmpeg/fftools/ffmpeg.c:2596
     #10 0x560528 in process_input
 /home/seviezhou/ffmpeg/fftools/ffmpeg.c:4493:5
     #11 0x560528 in transcode_step
 /home/seviezhou/ffmpeg/fftools/ffmpeg.c:4613
     #12 0x560528 in transcode /home/seviezhou/ffmpeg/fftools/ffmpeg.c:4667
     #13 0x555f45 in main /home/seviezhou/ffmpeg/fftools/ffmpeg.c:4872:9
     #14 0x7ffa992fbb96 in __libc_start_main /build/glibc-
 OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
     #15 0x41df89 in _start (/home/seviezhou/ffmpeg/ffmpeg_g+0x41df89)

 Address 0x7fffe9040e65 is located in stack of thread T0 at offset 165 in
 frame
     #0 0x2946f3f in aac_decode_frame
 /home/seviezhou/ffmpeg/libavcodec/aacdec_template.c:3409

   This frame has 4 object(s):
     [32, 64) 'gb.i' (line 1113)
     [96, 128) 'gb' (line 3413)
     [160, 164) 'new_extradata_size' (line 3417) <== Memory access at
 offset 165 overflows this variable
     [176, 180) 'jp_dualmono_size' (line 3421)
 HINT: this may be a false positive if your program uses some custom stack
 unwind mechanism or swapcontext
       (longjmp and C++ exceptions *are* supported)
 SUMMARY: AddressSanitizer: stack-buffer-overflow
 /home/seviezhou/ffmpeg/libavcodec/aacdec_template.c:539:24 in
 output_configure
 Shadow bytes around the buggy address:
   0x10007d200170: f8 f8 f8 f8 f8 f8 f8 f8 f2 f2 f2 f2 f2 f2 f2 f2
   0x10007d200180: 00 00 00 00 00 00 00 00 f2 f2 f2 f2 00 00 00 00
   0x10007d200190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   0x10007d2001a0: 00 00 00 00 f3 f3 f3 f3 f3 f3 f3 f3 00 00 00 00
   0x10007d2001b0: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 f8 f8 f8 f8
 =>0x10007d2001c0: f2 f2 f2 f2 00 00 00 00 f2 f2 f2 f2[04]f2 04 f3
   0x10007d2001d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   0x10007d2001e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   0x10007d2001f0: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
   0x10007d200200: 04 f2 f8 f3 00 00 00 00 00 00 00 00 00 00 00 00
   0x10007d200210: 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
 ==30448==ABORTING
 }}}

--
Ticket URL: <https://trac.ffmpeg.org/ticket/8860#comment:2>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list