GNOME Bugzilla – Bug 777957
mpegdemux: Invalid memory read in gst_ps_demux_parse_psm
Last modified: 2017-02-14 06:27:13 UTC
File: https://samples.mplayerhq.hu/ffmpeg-bugs/trac/ticket4182/alamic.mpg asan error: ==6863==ERROR: AddressSanitizer: SEGV on unknown address 0x62d0014f31a8 (pc 0x7f44fe7c0477 bp 0x62d0014f31a8 sp 0x7f44fe79a900 T2) ==6863==The signal is caused by a READ memory access. #0 0x7f44fe7c0476 in __gst_fast_read_swap16 /usr/include/gstreamer-1.0/gst/gstutils.h:128:10 #1 0x7f44fe7c0476 in gst_ps_demux_parse_psm /f/gstreamer/gst-plugins-bad/gst/mpegdemux/gstmpegdemux.c:2121 #2 0x7f44fe7c0476 in gst_ps_demux_chain /f/gstreamer/gst-plugins-bad/gst/mpegdemux/gstmpegdemux.c:3201 #3 0x7f44fe7bddeb in gst_ps_demux_pull_block /f/gstreamer/gst-plugins-bad/gst/mpegdemux/gstmpegdemux.c:2875:9 #4 0x7f44fe7b5eb1 in gst_ps_demux_loop /f/gstreamer/gst-plugins-bad/gst/mpegdemux/gstmpegdemux.c:2905:11 #5 0x7f450be3e983 in gst_task_func /f/gstreamer/gstreamer/gst/gsttask.c:335:5 #6 0x7f450b03bb2d in g_thread_pool_thread_proxy /var/tmp/portage/dev-libs/glib-2.50.2/work/glib-2.50.2/glib/gthreadpool.c:307 #7 0x7f450b03b154 in g_thread_proxy /var/tmp/portage/dev-libs/glib-2.50.2/work/glib-2.50.2/glib/gthread.c:784 #8 0x7f450aab9453 in start_thread (/lib64/libpthread.so.0+0x7453) #9 0x7f450a5e95dc in clone (/lib64/libc.so.6+0xe75dc) AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV /usr/include/gstreamer-1.0/gst/gstutils.h:128:10 in __gst_fast_read_swap16 Thread T2 (mpegpsdemux0:si) created by T1 (typefind:sink) here: #0 0x42df2d in __interceptor_pthread_create (/usr/bin/gst-discoverer-1.0+0x42df2d) #1 0x7f450b0581bf in g_system_thread_new /var/tmp/portage/dev-libs/glib-2.50.2/work/glib-2.50.2/glib/gthread-posix.c:1170 Thread T1 (typefind:sink) created by T0 here: #0 0x42df2d in __interceptor_pthread_create (/usr/bin/gst-discoverer-1.0+0x42df2d) #1 0x7f450b0581bf in g_system_thread_new /var/tmp/portage/dev-libs/glib-2.50.2/work/glib-2.50.2/glib/gthread-posix.c:1170 ==6863==ABORTING
valgrind does not seem to be complaining here
... but some length checks would be useful nonetheless here :)
Created attachment 344676 [details] [review] psdemux: Rewrite PSM parsing using GstByteReader Avoid possible buffer overflows and ignore invalid PSM packets better by using GstByteReader.
I also can't find the same error, but the psm parsing code definitely isn't safe. Here's a rewrite - thanks!
For those who want to cherry pick commit 948b87bf1514de55ee96575d204140eeec3a80a8 Author: Jan Schmidt <jan@centricular.com> Date: Wed Feb 1 14:25:32 2017 +1100 psdemux: Rewrite PSM parsing using GstByteReader Avoid possible buffer overflows and ignore invalid PSM packets better by using GstByteReader. https://bugzilla.gnome.org/show_bug.cgi?id=777957