diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2013-04-17 21:19:23 +0200 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2013-10-16 23:05:51 +0200 |
commit | 3cc05e0d9d24d0d6f2fdb1d49ec6b6d298816dae (patch) | |
tree | 1c1a67e44b7242b3802348c0b33fa69e2dec9684 /libavformat | |
parent | b98a824c3e97a2e40eb9fd5daa64001ecd4b7f5a (diff) | |
download | ffmpeg-3cc05e0d9d24d0d6f2fdb1d49ec6b6d298816dae.tar.gz |
oma: correctly mark and decrypt partial packets
Incomplete crypted files would lead to a read after buffer boundary
otherwise.
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
(cherry picked from commit 2219e27b5b17d146e4ab71a3ed86dfc013fb7a93)
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Conflicts:
libavformat/omadec.c
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/omadec.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libavformat/omadec.c b/libavformat/omadec.c index 860b876b8c..9e8b43b3c5 100644 --- a/libavformat/omadec.c +++ b/libavformat/omadec.c @@ -392,14 +392,22 @@ static int oma_read_packet(AVFormatContext *s, AVPacket *pkt) int packet_size = s->streams[0]->codec->block_align; int ret = av_get_packet(s->pb, pkt, packet_size); + if (ret < packet_size) + pkt->flags |= AV_PKT_FLAG_CORRUPT; + if (ret <= 0) return AVERROR(EIO); pkt->stream_index = 0; if (oc->encrypted) { - /* previous unencrypted block saved in IV for the next packet (CBC mode) */ - av_des_crypt(&oc->av_des, pkt->data, pkt->data, (packet_size >> 3), oc->iv, 1); + /* previous unencrypted block saved in IV for + * the next packet (CBC mode) */ + if (ret == packet_size) + av_des_crypt(&oc->av_des, pkt->data, pkt->data, + (packet_size >> 3), oc->iv, 1); + else + memset(oc->iv, 0, 8); } return ret; |