[FFmpeg-trac] #8266(undetermined:new): heap-use-after-free at libavformat/mpegenc.c:626

FFmpeg trac at avcodec.org
Sun Oct 13 19:12:37 EEST 2019


#8266: heap-use-after-free at libavformat/mpegenc.c:626
-------------------------------------+-------------------------------------
             Reporter:  Suhwan       |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:               |                  Version:  git-
  undetermined                       |  master
             Keywords:  asan         |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 Summary of the bug:
 There is a heap-use-after-free at libavformat/mpegenc.c:626 in
 get_nb_frames

 I compiled ffmpeg with "--toolchain=clang-asan" to check the memory
 corruption and attached log file.
 How to reproduce:
 {{{
 % ffmpeg_g -stream_loop 5 -y -i $PoC_1 -i $PoC_2 -target vcd -loglevel 8
 -map 0 -c copy -c:v:143 pcm_u16be -disposition:s:8 pcm_f32le tmp.adp

 ffmpeg version N-95336-g4f4334bcbc Copyright (c) 2000-2019 the FFmpeg
 developers
 built with clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
 configuration: --cc=clang --cxx=clang++ --ld=clang --enable-debug
 --toolchain=clang-asan
 }}}

 Here's ASAN log

 {{{
 =================================================================
 ==18825==ERROR: AddressSanitizer: heap-use-after-free on address
 0x6090001f0b50 at pc 0x0000022ba732 bp 0x7fffffffa470 sp 0x7fffffffa468
 READ of size 4 at 0x6090001f0b50 thread T0
     #0 0x22ba731 in get_nb_frames ffmpeg/libavformat/mpegenc.c:626:23
     #1 0x22ba731 in flush_packet ffmpeg/libavformat/mpegenc.c:836
     #2 0x22afe3a in output_packet ffmpeg/libavformat/mpegenc.c:1106:19
     #3 0x22ac0e3 in mpeg_mux_write_packet
 ffmpeg/libavformat/mpegenc.c:1229:19
     #4 0x2378743 in write_packet ffmpeg/libavformat/mux.c:747:15
     #5 0x238609b in av_interleaved_write_frame
 ffmpeg/libavformat/mux.c:1238:15
     #6 0x63bb0e in write_packet ffmpeg/fftools/ffmpeg.c:815:11
     #7 0x6140b4 in do_streamcopy ffmpeg/fftools/ffmpeg.c
     #8 0x6140b4 in process_input_packet ffmpeg/fftools/ffmpeg.c:2736
     #9 0x64a707 in process_input ffmpeg/fftools/ffmpeg.c:4508:5
     #10 0x5e7157 in transcode_step ffmpeg/fftools/ffmpeg.c:4628:11
     #11 0x5e7157 in transcode ffmpeg/fftools/ffmpeg.c:4682
     #12 0x5db65b in main ffmpeg/fftools/ffmpeg.c:4884:9
     #13 0x7ffff5c93b96 in __libc_start_main /build/glibc-
 OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
     #14 0x41def9 in _start (ffmpeg_asan+0x41def9)

 0x6090001f0b50 is located 16 bytes inside of 32-byte region
 [0x6090001f0b40,0x6090001f0b60)
 freed by thread T0 here:
     #0 0x4ddbe0 in __interceptor_free.localalias.0 (ffmpeg_asan+0x4ddbe0)
     #1 0x22b30be in remove_decoded_packets
 ffmpeg/libavformat/mpegenc.c:994:13
     #2 0x22ade08 in output_packet ffmpeg/libavformat/mpegenc.c:1071:17

 previously allocated by thread T0 here:
     #0 0x4de9e8 in posix_memalign (ffmpeg_asan+0x4de9e8)
     #1 0x8599368 in av_malloc ffmpeg/libavutil/mem.c:87:9
     #2 0x8599368 in av_mallocz ffmpeg/libavutil/mem.c:238
     #3 0x22ab73b in mpeg_mux_write_packet
 ffmpeg/libavformat/mpegenc.c:1188:32

 SUMMARY: AddressSanitizer: heap-use-after-free
 ffmpeg/libavformat/mpegenc.c:626:23 in get_nb_frames

 }}}
 Please confirm.
 Thanks

--
Ticket URL: <https://trac.ffmpeg.org/ticket/8266>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list