• Andreas Rheinhardt's avatar
    avformat/matroskadec: Fix use-after-free when demuxing ProRes · af50f0a5
    Andreas Rheinhardt authored
    ProRes in Matroska is supposed to not contain the first atom header
    (containing a size field and the tag "icpf") and therefore the Matroska
    demuxer has to recreate it; this involves an allocation and copy, of
    course. Whether the old buffer (containing the data without the atom
    header) needs to be freed or not depends upon whether it is what was
    directly read (in which case it is owned by an AVBuffer) or whether it
    has been allocated when reversing the track's content compression (e.g.
    zlib compression) that Matroska supports.
    
    So there are three pointers involved: The one pointing to the directly
    read data (owned by the AVBuffer), the one pointing to the currently
    valid data (which coincides with the former if no content compression
    needed to be reverted) and the one pointing to the new data with the
    first atom header. The check for whether to free the second of these is
    simply whether the first two are different.
    
    This works mostly, but there is a complication: Some muxers don't strip
    the first atom header away and in this case, it is also not reinserted
    and no new buffer is allocated; instead, the second and the third
    pointers agree. In this case, one must never free the second buffer.
    Yet it is currently done if the track is e.g. zlib compressed.
    This commit fixes this.
    
    This is a regression since b8e75a2a.
    Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
    Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
    af50f0a5
Name
Last commit
Last update
..
tests Loading commit data...
.gitignore Loading commit data...
3dostr.c Loading commit data...
4xm.c Loading commit data...
Makefile Loading commit data...
a64.c Loading commit data...
aacdec.c Loading commit data...
aadec.c Loading commit data...
ac3dec.c Loading commit data...
acm.c Loading commit data...
act.c Loading commit data...
adp.c Loading commit data...
ads.c Loading commit data...
adtsenc.c Loading commit data...
adxdec.c Loading commit data...
aea.c Loading commit data...
afc.c Loading commit data...
aiff.h Loading commit data...
aiffdec.c Loading commit data...
aiffenc.c Loading commit data...
aixdec.c Loading commit data...
allformats.c Loading commit data...
amr.c Loading commit data...
anm.c Loading commit data...
apc.c Loading commit data...
ape.c Loading commit data...
apetag.c Loading commit data...
apetag.h Loading commit data...
apngdec.c Loading commit data...
apngenc.c Loading commit data...
aptxdec.c Loading commit data...
aqtitledec.c Loading commit data...
asf.c Loading commit data...
asf.h Loading commit data...
asfcrypt.c Loading commit data...
asfcrypt.h Loading commit data...
asfdec_f.c Loading commit data...
asfdec_o.c Loading commit data...
asfenc.c Loading commit data...
assdec.c Loading commit data...
assenc.c Loading commit data...
ast.c Loading commit data...
ast.h Loading commit data...
astdec.c Loading commit data...
astenc.c Loading commit data...
async.c Loading commit data...
au.c Loading commit data...
audiointerleave.c Loading commit data...
audiointerleave.h Loading commit data...
av1.c Loading commit data...
av1.h Loading commit data...
av1dec.c Loading commit data...
avc.c Loading commit data...
avc.h Loading commit data...
avformat.h Loading commit data...
avformatres.rc Loading commit data...
avi.h Loading commit data...
avidec.c Loading commit data...
avienc.c Loading commit data...
avio.c Loading commit data...
avio.h Loading commit data...
avio_internal.h Loading commit data...
aviobuf.c Loading commit data...
avisynth.c Loading commit data...
avlanguage.c Loading commit data...
avlanguage.h Loading commit data...
avr.c Loading commit data...
avs.c Loading commit data...
bethsoftvid.c Loading commit data...
bfi.c Loading commit data...
bink.c Loading commit data...
bintext.c Loading commit data...
bit.c Loading commit data...
bluray.c Loading commit data...
bmv.c Loading commit data...
boadec.c Loading commit data...
brstm.c Loading commit data...
c93.c Loading commit data...
cache.c Loading commit data...
caf.c Loading commit data...
caf.h Loading commit data...
cafdec.c Loading commit data...
cafenc.c Loading commit data...
cavsvideodec.c Loading commit data...
cdg.c Loading commit data...
cdxl.c Loading commit data...
chromaprint.c Loading commit data...
cinedec.c Loading commit data...
codec2.c Loading commit data...
concat.c Loading commit data...
concatdec.c Loading commit data...
crcenc.c Loading commit data...
crypto.c Loading commit data...
cutils.c Loading commit data...
dash.c Loading commit data...
dash.h Loading commit data...
dashdec.c Loading commit data...
dashenc.c Loading commit data...
data_uri.c Loading commit data...
dauddec.c Loading commit data...
daudenc.c Loading commit data...
davs2.c Loading commit data...
dcstr.c Loading commit data...
dfa.c Loading commit data...
dhav.c Loading commit data...
diracdec.c Loading commit data...
dnxhddec.c Loading commit data...
dsfdec.c Loading commit data...
dsicin.c Loading commit data...
dss.c Loading commit data...
dtsdec.c Loading commit data...
dtshddec.c Loading commit data...
dump.c Loading commit data...
dv.c Loading commit data...
dv.h Loading commit data...
dvbsub.c Loading commit data...
dvbtxt.c Loading commit data...
dvenc.c Loading commit data...
dxa.c Loading commit data...
eacdata.c Loading commit data...
electronicarts.c Loading commit data...
epafdec.c Loading commit data...
ffmeta.h Loading commit data...
ffmetadec.c Loading commit data...
ffmetaenc.c Loading commit data...
fifo.c Loading commit data...
fifo_test.c Loading commit data...
file.c Loading commit data...
file_open.c Loading commit data...
filmstripdec.c Loading commit data...
filmstripenc.c Loading commit data...
fitsdec.c Loading commit data...
fitsenc.c Loading commit data...
flac_picture.c Loading commit data...
flac_picture.h Loading commit data...
flacdec.c Loading commit data...
flacenc.c Loading commit data...
flacenc.h Loading commit data...
flacenc_header.c Loading commit data...
flic.c Loading commit data...
flv.h Loading commit data...
flvdec.c Loading commit data...
flvenc.c Loading commit data...
format.c Loading commit data...
framecrcenc.c Loading commit data...
framehash.c Loading commit data...
frmdec.c Loading commit data...
fsb.c Loading commit data...
ftp.c Loading commit data...
g722.c Loading commit data...
g723_1.c Loading commit data...
g726.c Loading commit data...
g729dec.c Loading commit data...
gdv.c Loading commit data...
genh.c Loading commit data...
gif.c Loading commit data...
gifdec.c Loading commit data...
golomb_tab.c Loading commit data...
gopher.c Loading commit data...
gsmdec.c Loading commit data...
gxf.c Loading commit data...
gxf.h Loading commit data...
gxfenc.c Loading commit data...
h261dec.c Loading commit data...
h263dec.c Loading commit data...
h264dec.c Loading commit data...
hashenc.c Loading commit data...
hcom.c Loading commit data...
hdsenc.c Loading commit data...
hevc.c Loading commit data...
hevc.h Loading commit data...
hevcdec.c Loading commit data...
hls.c Loading commit data...
hlsenc.c Loading commit data...
hlsplaylist.c Loading commit data...
hlsplaylist.h Loading commit data...
hlsproto.c Loading commit data...
hnm.c Loading commit data...
http.c Loading commit data...
http.h Loading commit data...
httpauth.c Loading commit data...
httpauth.h Loading commit data...
icecast.c Loading commit data...
icodec.c Loading commit data...
icoenc.c Loading commit data...
id3v1.c Loading commit data...
id3v1.h Loading commit data...
id3v2.c Loading commit data...
id3v2.h Loading commit data...
id3v2enc.c Loading commit data...
idcin.c Loading commit data...
idroqdec.c Loading commit data...
idroqenc.c Loading commit data...
iff.c Loading commit data...
ifv.c Loading commit data...
ilbc.c Loading commit data...
img2.c Loading commit data...
img2.h Loading commit data...
img2_alias_pix.c Loading commit data...
img2_brender_pix.c Loading commit data...
img2dec.c Loading commit data...
img2enc.c Loading commit data...
ingenientdec.c Loading commit data...
internal.h Loading commit data...
ip.c Loading commit data...
ip.h Loading commit data...
ipmovie.c Loading commit data...
ircam.c Loading commit data...
ircam.h Loading commit data...
ircamdec.c Loading commit data...
ircamenc.c Loading commit data...
isom.c Loading commit data...
isom.h Loading commit data...
iss.c Loading commit data...
iv8.c Loading commit data...
ivfdec.c Loading commit data...
ivfenc.c Loading commit data...
jacosubdec.c Loading commit data...
jacosubenc.c Loading commit data...
jvdec.c Loading commit data...
latmenc.c Loading commit data...
libavformat.v Loading commit data...
libgme.c Loading commit data...
libmodplug.c Loading commit data...
libopenmpt.c Loading commit data...
librtmp.c Loading commit data...
libsmbclient.c Loading commit data...
libsrt.c Loading commit data...
libssh.c Loading commit data...
libzmq.c Loading commit data...
lmlm4.c Loading commit data...
loasdec.c Loading commit data...
log2_tab.c Loading commit data...
lrc.c Loading commit data...
lrc.h Loading commit data...
lrcdec.c Loading commit data...
lrcenc.c Loading commit data...
lvfdec.c Loading commit data...
lxfdec.c Loading commit data...
m4vdec.c Loading commit data...
matroska.c Loading commit data...
matroska.h Loading commit data...
matroskadec.c Loading commit data...
matroskaenc.c Loading commit data...
md5proto.c Loading commit data...
metadata.c Loading commit data...
metadata.h Loading commit data...
mgsts.c Loading commit data...
microdvddec.c Loading commit data...
microdvdenc.c Loading commit data...
mj2kdec.c Loading commit data...
mkvtimestamp_v2.c Loading commit data...
mlpdec.c Loading commit data...
mlvdec.c Loading commit data...
mm.c Loading commit data...
mmf.c Loading commit data...
mms.c Loading commit data...
mms.h Loading commit data...
mmsh.c Loading commit data...
mmst.c Loading commit data...
mov.c Loading commit data...
mov_chan.c Loading commit data...
mov_chan.h Loading commit data...
mov_esds.c Loading commit data...
movenc.c Loading commit data...
movenc.h Loading commit data...
movenccenc.c Loading commit data...
movenccenc.h Loading commit data...
movenchint.c Loading commit data...
mp3dec.c Loading commit data...
mp3enc.c Loading commit data...
mpc.c Loading commit data...
mpc8.c Loading commit data...
mpeg.c Loading commit data...
mpeg.h Loading commit data...
mpegenc.c Loading commit data...
mpegts.c Loading commit data...
mpegts.h Loading commit data...
mpegtsenc.c Loading commit data...
mpegvideodec.c Loading commit data...
mpjpeg.c Loading commit data...
mpjpegdec.c Loading commit data...
mpl2dec.c Loading commit data...
mpsubdec.c Loading commit data...
msf.c Loading commit data...
msnwc_tcp.c Loading commit data...
mtaf.c Loading commit data...
mtv.c Loading commit data...
musx.c Loading commit data...
mux.c Loading commit data...
mvdec.c Loading commit data...
mvi.c Loading commit data...
mxf.c Loading commit data...
mxf.h Loading commit data...
mxfdec.c Loading commit data...
mxfenc.c Loading commit data...
mxg.c Loading commit data...
ncdec.c Loading commit data...
network.c Loading commit data...
network.h Loading commit data...
nistspheredec.c Loading commit data...
nspdec.c Loading commit data...
nsvdec.c Loading commit data...
nullenc.c Loading commit data...
nut.c Loading commit data...
nut.h Loading commit data...
nutdec.c Loading commit data...
nutenc.c Loading commit data...
nuv.c Loading commit data...
oggdec.c Loading commit data...
oggdec.h Loading commit data...
oggenc.c Loading commit data...
oggparsecelt.c Loading commit data...
oggparsedaala.c Loading commit data...
oggparsedirac.c Loading commit data...
oggparseflac.c Loading commit data...
oggparseogm.c Loading commit data...
oggparseopus.c Loading commit data...
oggparseskeleton.c Loading commit data...
oggparsespeex.c Loading commit data...
oggparsetheora.c Loading commit data...
oggparsevorbis.c Loading commit data...
oggparsevp8.c Loading commit data...
oma.c Loading commit data...
oma.h Loading commit data...
omadec.c Loading commit data...
omaenc.c Loading commit data...
options.c Loading commit data...
options_table.h Loading commit data...
os_support.c Loading commit data...
os_support.h Loading commit data...
paf.c Loading commit data...
pcm.c Loading commit data...
pcm.h Loading commit data...
pcmdec.c Loading commit data...
pcmenc.c Loading commit data...
pjsdec.c Loading commit data...
pmpdec.c Loading commit data...
prompeg.c Loading commit data...
protocols.c Loading commit data...
psxstr.c Loading commit data...
pva.c Loading commit data...
pvfdec.c Loading commit data...
qcp.c Loading commit data...
qtpalette.c Loading commit data...
qtpalette.h Loading commit data...
r3d.c Loading commit data...
rawdec.c Loading commit data...
rawdec.h Loading commit data...
rawenc.c Loading commit data...
rawenc.h Loading commit data...
rawutils.c Loading commit data...
rawvideodec.c Loading commit data...
rdt.c Loading commit data...
rdt.h Loading commit data...
realtextdec.c Loading commit data...
redspark.c Loading commit data...
replaygain.c Loading commit data...
replaygain.h Loading commit data...
riff.c Loading commit data...
riff.h Loading commit data...
riffdec.c Loading commit data...
riffenc.c Loading commit data...
rl2.c Loading commit data...
rm.c Loading commit data...
rm.h Loading commit data...
rmdec.c Loading commit data...
rmenc.c Loading commit data...
rmsipr.c Loading commit data...
rmsipr.h Loading commit data...
rpl.c Loading commit data...
rsd.c Loading commit data...
rso.c Loading commit data...
rso.h Loading commit data...
rsodec.c Loading commit data...
rsoenc.c Loading commit data...
rtmp.h Loading commit data...
rtmpcrypt.c Loading commit data...
rtmpcrypt.h Loading commit data...
rtmpdh.c Loading commit data...
rtmpdh.h Loading commit data...
rtmpdigest.c Loading commit data...
rtmphttp.c Loading commit data...
rtmppkt.c Loading commit data...
rtmppkt.h Loading commit data...
rtmpproto.c Loading commit data...
rtp.c Loading commit data...
rtp.h Loading commit data...
rtpdec.c Loading commit data...
rtpdec.h Loading commit data...
rtpdec_ac3.c Loading commit data...
rtpdec_amr.c Loading commit data...
rtpdec_asf.c Loading commit data...
rtpdec_dv.c Loading commit data...
rtpdec_formats.h Loading commit data...
rtpdec_g726.c Loading commit data...
rtpdec_h261.c Loading commit data...
rtpdec_h263.c Loading commit data...
rtpdec_h263_rfc2190.c Loading commit data...
rtpdec_h264.c Loading commit data...
rtpdec_hevc.c Loading commit data...
rtpdec_ilbc.c Loading commit data...
rtpdec_jpeg.c Loading commit data...
rtpdec_latm.c Loading commit data...
rtpdec_mpa_robust.c Loading commit data...
rtpdec_mpeg12.c Loading commit data...
rtpdec_mpeg4.c Loading commit data...
rtpdec_mpegts.c Loading commit data...
rtpdec_qcelp.c Loading commit data...
rtpdec_qdm2.c Loading commit data...
rtpdec_qt.c Loading commit data...
rtpdec_rfc4175.c Loading commit data...
rtpdec_svq3.c Loading commit data...
rtpdec_vc2hq.c Loading commit data...
rtpdec_vp8.c Loading commit data...
rtpdec_vp9.c Loading commit data...
rtpdec_xiph.c Loading commit data...
rtpenc.c Loading commit data...
rtpenc.h Loading commit data...
rtpenc_aac.c Loading commit data...
rtpenc_amr.c Loading commit data...
rtpenc_chain.c Loading commit data...
rtpenc_chain.h Loading commit data...
rtpenc_h261.c Loading commit data...
rtpenc_h263.c Loading commit data...
rtpenc_h263_rfc2190.c Loading commit data...
rtpenc_h264_hevc.c Loading commit data...
rtpenc_jpeg.c Loading commit data...
rtpenc_latm.c Loading commit data...
rtpenc_mpegts.c Loading commit data...
rtpenc_mpv.c Loading commit data...
rtpenc_vc2hq.c Loading commit data...
rtpenc_vp8.c Loading commit data...
rtpenc_vp9.c Loading commit data...
rtpenc_xiph.c Loading commit data...
rtpproto.c Loading commit data...
rtpproto.h Loading commit data...
rtsp.c Loading commit data...
rtsp.h Loading commit data...
rtspcodes.h Loading commit data...
rtspdec.c Loading commit data...
rtspenc.c Loading commit data...
s337m.c Loading commit data...
samidec.c Loading commit data...
sapdec.c Loading commit data...
sapenc.c Loading commit data...
sauce.c Loading commit data...
sauce.h Loading commit data...
sbcdec.c Loading commit data...
sbgdec.c Loading commit data...
sccdec.c Loading commit data...
sccenc.c Loading commit data...
sctp.c Loading commit data...
sdp.c Loading commit data...
sdr2.c Loading commit data...
sdsdec.c Loading commit data...
sdxdec.c Loading commit data...
segafilm.c Loading commit data...
segafilmenc.c Loading commit data...
segment.c Loading commit data...
serdec.c Loading commit data...
shortendec.c Loading commit data...
sierravmd.c Loading commit data...
siff.c Loading commit data...
smacker.c Loading commit data...
smjpeg.c Loading commit data...
smjpeg.h Loading commit data...
smjpegdec.c Loading commit data...
smjpegenc.c Loading commit data...
smoothstreamingenc.c Loading commit data...
smush.c Loading commit data...
sol.c Loading commit data...
sox.h Loading commit data...
soxdec.c Loading commit data...
soxenc.c Loading commit data...
spdif.c Loading commit data...
spdif.h Loading commit data...
spdifdec.c Loading commit data...
spdifenc.c Loading commit data...
srtdec.c Loading commit data...
srtenc.c Loading commit data...
srtp.c Loading commit data...
srtp.h Loading commit data...
srtpproto.c Loading commit data...
stldec.c Loading commit data...
subfile.c Loading commit data...
subtitles.c Loading commit data...
subtitles.h Loading commit data...
subviewer1dec.c Loading commit data...
subviewerdec.c Loading commit data...
supdec.c Loading commit data...
supenc.c Loading commit data...
svag.c Loading commit data...
swf.c Loading commit data...
swf.h Loading commit data...
swfdec.c Loading commit data...
swfenc.c Loading commit data...
takdec.c Loading commit data...
tcp.c Loading commit data...
tedcaptionsdec.c Loading commit data...
tee.c Loading commit data...
tee_common.c Loading commit data...
tee_common.h Loading commit data...
teeproto.c Loading commit data...
thp.c Loading commit data...
tiertexseq.c Loading commit data...
tls.c Loading commit data...
tls.h Loading commit data...
tls_gnutls.c Loading commit data...
tls_libtls.c Loading commit data...
tls_mbedtls.c Loading commit data...
tls_openssl.c Loading commit data...
tls_schannel.c Loading commit data...
tls_securetransport.c Loading commit data...
tmv.c Loading commit data...
tta.c Loading commit data...
ttaenc.c Loading commit data...
tty.c Loading commit data...
txd.c Loading commit data...
ty.c Loading commit data...
udp.c Loading commit data...
uncodedframecrcenc.c Loading commit data...
unix.c Loading commit data...
url.c Loading commit data...
url.h Loading commit data...
urldecode.c Loading commit data...
urldecode.h Loading commit data...
utils.c Loading commit data...
v210.c Loading commit data...
vag.c Loading commit data...
vapoursynth.c Loading commit data...
vc1dec.c Loading commit data...
vc1test.c Loading commit data...
vc1testenc.c Loading commit data...
version.h Loading commit data...
vividas.c Loading commit data...
vivo.c Loading commit data...
voc.c Loading commit data...
voc.h Loading commit data...
voc_packet.c Loading commit data...
vocdec.c Loading commit data...
vocenc.c Loading commit data...
vorbiscomment.c Loading commit data...
vorbiscomment.h Loading commit data...
vpcc.c Loading commit data...
vpcc.h Loading commit data...
vpk.c Loading commit data...
vplayerdec.c Loading commit data...
vqf.c Loading commit data...
w64.c Loading commit data...
w64.h Loading commit data...
wavdec.c Loading commit data...
wavenc.c Loading commit data...
wc3movie.c Loading commit data...
webm_chunk.c Loading commit data...
webmdashenc.c Loading commit data...
webpenc.c Loading commit data...
webvttdec.c Loading commit data...
webvttenc.c Loading commit data...
westwood_aud.c Loading commit data...
westwood_vqa.c Loading commit data...
wsddec.c Loading commit data...
wtv.h Loading commit data...
wtv_common.c Loading commit data...
wtvdec.c Loading commit data...
wtvenc.c Loading commit data...
wv.c Loading commit data...
wv.h Loading commit data...
wvdec.c Loading commit data...
wvedec.c Loading commit data...
wvenc.c Loading commit data...
xa.c Loading commit data...
xmv.c Loading commit data...
xvag.c Loading commit data...
xwma.c Loading commit data...
yop.c Loading commit data...
yuv4mpeg.h Loading commit data...
yuv4mpegdec.c Loading commit data...
yuv4mpegenc.c Loading commit data...