mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
avformat/asfdec_o: Use ff_get_extradata()
Fixes: OOM
Fixes: 27240/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_O_fuzzer-5937469859823616
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 098314e1e5
)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
aee30a18c7
commit
04abdd5154
@ -684,7 +684,7 @@ static int asf_read_properties(AVFormatContext *s, const GUIDParseTable *g)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_video_info(AVIOContext *pb, AVStream *st)
|
static int parse_video_info(AVFormatContext *avfmt, AVIOContext *pb, AVStream *st)
|
||||||
{
|
{
|
||||||
uint16_t size_asf; // ASF-specific Format Data size
|
uint16_t size_asf; // ASF-specific Format Data size
|
||||||
uint32_t size_bmp; // BMP_HEADER-specific Format Data size
|
uint32_t size_bmp; // BMP_HEADER-specific Format Data size
|
||||||
@ -699,19 +699,10 @@ static int parse_video_info(AVIOContext *pb, AVStream *st)
|
|||||||
st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag);
|
st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag);
|
||||||
size_bmp = FFMAX(size_asf, size_bmp);
|
size_bmp = FFMAX(size_asf, size_bmp);
|
||||||
|
|
||||||
if (size_bmp > BMP_HEADER_SIZE &&
|
if (size_bmp > BMP_HEADER_SIZE) {
|
||||||
size_bmp < INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) {
|
int ret = ff_get_extradata(avfmt, st->codecpar, pb, size_bmp - BMP_HEADER_SIZE);
|
||||||
int ret;
|
|
||||||
st->codecpar->extradata_size = size_bmp - BMP_HEADER_SIZE;
|
if (ret < 0)
|
||||||
if (!(st->codecpar->extradata = av_malloc(st->codecpar->extradata_size +
|
|
||||||
AV_INPUT_BUFFER_PADDING_SIZE))) {
|
|
||||||
st->codecpar->extradata_size = 0;
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
memset(st->codecpar->extradata + st->codecpar->extradata_size , 0,
|
|
||||||
AV_INPUT_BUFFER_PADDING_SIZE);
|
|
||||||
if ((ret = avio_read(pb, st->codecpar->extradata,
|
|
||||||
st->codecpar->extradata_size)) < 0)
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -792,7 +783,7 @@ static int asf_read_stream_properties(AVFormatContext *s, const GUIDParseTable *
|
|||||||
break;
|
break;
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
asf_st->type = AVMEDIA_TYPE_VIDEO;
|
asf_st->type = AVMEDIA_TYPE_VIDEO;
|
||||||
if ((ret = parse_video_info(pb, st)) < 0)
|
if ((ret = parse_video_info(s, pb, st)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user