diff options
author | Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> | 2015-12-19 12:02:56 +0100 |
---|---|---|
committer | Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> | 2015-12-20 13:39:41 +0100 |
commit | 174ec7d744d3e45bdb74c4c568f7bc5f689d4304 (patch) | |
tree | 576220b8e3b9a4f5b1fc18a651155ac1740a5a92 /libavformat | |
parent | 778c8de40f2c8d8bdbdf9a52306c59b6a425d401 (diff) | |
download | ffmpeg-174ec7d744d3e45bdb74c4c568f7bc5f689d4304.tar.gz |
nutdec: reject negative value_len in read_sm_data
If it is negative, it can cause the byte position to move backwards in
avio_skip, which in turn makes sm_size negative and thus size larger
than the size of the packet buffer, causing invalid writes in avio_read.
Also fix potential overflow of avio_tell(bc) + value_len.
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
(cherry picked from commit ce10f572c12b0d172c72d31d8c979afce602bf0c)
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/nutdec.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 201c34e0e9..bfa2bade27 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -927,7 +927,7 @@ static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int return ret; } value_len = ffio_read_varlen(bc); - if (avio_tell(bc) + value_len >= maxpos) + if (value_len < 0 || value_len >= maxpos - avio_tell(bc)) return AVERROR_INVALIDDATA; if (!strcmp(name, "Palette")) { dst = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, value_len); |