mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-03-08 13:38:07 +00:00
swf: check return values for av_get/new_packet().
Prevents crashers when using the packet if allocation failed. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org
This commit is contained in:
parent
480b133e6f
commit
31632e73f4
@ -84,7 +84,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
SWFContext *swf = s->priv_data;
|
SWFContext *swf = s->priv_data;
|
||||||
AVIOContext *pb = s->pb;
|
AVIOContext *pb = s->pb;
|
||||||
AVStream *vst = NULL, *ast = NULL, *st = 0;
|
AVStream *vst = NULL, *ast = NULL, *st = 0;
|
||||||
int tag, len, i, frame, v;
|
int tag, len, i, frame, v, res;
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
uint64_t pos = avio_tell(pb);
|
uint64_t pos = avio_tell(pb);
|
||||||
@ -147,7 +147,8 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
st = s->streams[i];
|
st = s->streams[i];
|
||||||
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == ch_id) {
|
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == ch_id) {
|
||||||
frame = avio_rl16(pb);
|
frame = avio_rl16(pb);
|
||||||
av_get_packet(pb, pkt, len-2);
|
if ((res = av_get_packet(pb, pkt, len-2)) < 0)
|
||||||
|
return res;
|
||||||
pkt->pos = pos;
|
pkt->pos = pos;
|
||||||
pkt->pts = frame;
|
pkt->pts = frame;
|
||||||
pkt->stream_index = st->index;
|
pkt->stream_index = st->index;
|
||||||
@ -160,9 +161,11 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1) {
|
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1) {
|
||||||
if (st->codec->codec_id == CODEC_ID_MP3) {
|
if (st->codec->codec_id == CODEC_ID_MP3) {
|
||||||
avio_skip(pb, 4);
|
avio_skip(pb, 4);
|
||||||
av_get_packet(pb, pkt, len-4);
|
if ((res = av_get_packet(pb, pkt, len-4)) < 0)
|
||||||
|
return res;
|
||||||
} else { // ADPCM, PCM
|
} else { // ADPCM, PCM
|
||||||
av_get_packet(pb, pkt, len);
|
if ((res = av_get_packet(pb, pkt, len)) < 0)
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
pkt->pos = pos;
|
pkt->pos = pos;
|
||||||
pkt->stream_index = st->index;
|
pkt->stream_index = st->index;
|
||||||
@ -187,7 +190,8 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
st = vst;
|
st = vst;
|
||||||
}
|
}
|
||||||
avio_rl16(pb); /* BITMAP_ID */
|
avio_rl16(pb); /* BITMAP_ID */
|
||||||
av_new_packet(pkt, len-2);
|
if ((res = av_new_packet(pkt, len-2)) < 0)
|
||||||
|
return res;
|
||||||
avio_read(pb, pkt->data, 4);
|
avio_read(pb, pkt->data, 4);
|
||||||
if (AV_RB32(pkt->data) == 0xffd8ffd9 ||
|
if (AV_RB32(pkt->data) == 0xffd8ffd9 ||
|
||||||
AV_RB32(pkt->data) == 0xffd9ffd8) {
|
AV_RB32(pkt->data) == 0xffd9ffd8) {
|
||||||
|
Loading…
Reference in New Issue
Block a user