mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2024-11-23 19:49:56 +00:00
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
This commit is contained in:
parent
9d0b45ade8
commit
2219e27b5b
@ -405,6 +405,9 @@ 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 ret;
|
||||
if (!ret)
|
||||
@ -415,8 +418,11 @@ static int oma_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
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);
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user