You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avcodec/h264: Increase field_poc to 64bit in ff_h264_init_poc() to detect overflows
Fixes: Integer overflow Fixes: 5746/clusterfuzz-testcase-minimized-6270097623613440 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
@@ -271,7 +271,7 @@ int ff_h264_init_poc(int pic_field_poc[2], int *pic_poc,
|
|||||||
int picture_structure, int nal_ref_idc)
|
int picture_structure, int nal_ref_idc)
|
||||||
{
|
{
|
||||||
const int max_frame_num = 1 << sps->log2_max_frame_num;
|
const int max_frame_num = 1 << sps->log2_max_frame_num;
|
||||||
int field_poc[2];
|
int64_t field_poc[2];
|
||||||
|
|
||||||
pc->frame_num_offset = pc->prev_frame_num_offset;
|
pc->frame_num_offset = pc->prev_frame_num_offset;
|
||||||
if (pc->frame_num < pc->prev_frame_num)
|
if (pc->frame_num < pc->prev_frame_num)
|
||||||
@@ -337,6 +337,10 @@ int ff_h264_init_poc(int pic_field_poc[2], int *pic_poc,
|
|||||||
field_poc[1] = poc;
|
field_poc[1] = poc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( field_poc[0] != (int)field_poc[0]
|
||||||
|
|| field_poc[1] != (int)field_poc[1])
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if (picture_structure != PICT_BOTTOM_FIELD)
|
if (picture_structure != PICT_BOTTOM_FIELD)
|
||||||
pic_field_poc[0] = field_poc[0];
|
pic_field_poc[0] = field_poc[0];
|
||||||
if (picture_structure != PICT_TOP_FIELD)
|
if (picture_structure != PICT_TOP_FIELD)
|
||||||
|
@@ -449,8 +449,10 @@ static inline int parse_nal_units(AVCodecParserContext *s,
|
|||||||
/* Decode POC of this picture.
|
/* Decode POC of this picture.
|
||||||
* The prev_ values needed for decoding POC of the next picture are not set here. */
|
* The prev_ values needed for decoding POC of the next picture are not set here. */
|
||||||
field_poc[0] = field_poc[1] = INT_MAX;
|
field_poc[0] = field_poc[1] = INT_MAX;
|
||||||
ff_h264_init_poc(field_poc, &s->output_picture_number, sps,
|
ret = ff_h264_init_poc(field_poc, &s->output_picture_number, sps,
|
||||||
&p->poc, p->picture_structure, nal.ref_idc);
|
&p->poc, p->picture_structure, nal.ref_idc);
|
||||||
|
if (ret < 0)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
/* Continue parsing to check if MMCO_RESET is present.
|
/* Continue parsing to check if MMCO_RESET is present.
|
||||||
* FIXME: MMCO_RESET could appear in non-first slice.
|
* FIXME: MMCO_RESET could appear in non-first slice.
|
||||||
|
@@ -1607,8 +1607,10 @@ static int h264_field_start(H264Context *h, const H264SliceContext *sl,
|
|||||||
(h->mb_height * h->mb_stride - 1) * sizeof(*h->slice_table));
|
(h->mb_height * h->mb_stride - 1) * sizeof(*h->slice_table));
|
||||||
}
|
}
|
||||||
|
|
||||||
ff_h264_init_poc(h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc,
|
ret = ff_h264_init_poc(h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc,
|
||||||
h->ps.sps, &h->poc, h->picture_structure, nal->ref_idc);
|
h->ps.sps, &h->poc, h->picture_structure, nal->ref_idc);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
memcpy(h->mmco, sl->mmco, sl->nb_mmco * sizeof(*h->mmco));
|
memcpy(h->mmco, sl->mmco, sl->nb_mmco * sizeof(*h->mmco));
|
||||||
h->nb_mmco = sl->nb_mmco;
|
h->nb_mmco = sl->nb_mmco;
|
||||||
|
Reference in New Issue
Block a user