avcodec/xsubdec: Check parse_timecode()
Fixes: CID1604490 Overflowed constant Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 96fd9417e250540f228d1ad5b43a77c120208eba) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
5fd805dfb4
commit
8cc5348df6
@ -59,6 +59,7 @@ static int decode_frame(AVCodecContext *avctx, AVSubtitle *sub,
|
|||||||
int64_t packet_time = 0;
|
int64_t packet_time = 0;
|
||||||
GetBitContext gb;
|
GetBitContext gb;
|
||||||
int has_alpha = avctx->codec_tag == MKTAG('D','X','S','A');
|
int has_alpha = avctx->codec_tag == MKTAG('D','X','S','A');
|
||||||
|
int64_t start_display_time, end_display_time;
|
||||||
|
|
||||||
// check that at least header fits
|
// check that at least header fits
|
||||||
if (buf_size < 27 + 7 * 2 + 4 * (3 + has_alpha)) {
|
if (buf_size < 27 + 7 * 2 + 4 * (3 + has_alpha)) {
|
||||||
@ -73,8 +74,14 @@ static int decode_frame(AVCodecContext *avctx, AVSubtitle *sub,
|
|||||||
}
|
}
|
||||||
if (avpkt->pts != AV_NOPTS_VALUE)
|
if (avpkt->pts != AV_NOPTS_VALUE)
|
||||||
packet_time = av_rescale_q(avpkt->pts, AV_TIME_BASE_Q, (AVRational){1, 1000});
|
packet_time = av_rescale_q(avpkt->pts, AV_TIME_BASE_Q, (AVRational){1, 1000});
|
||||||
sub->start_display_time = parse_timecode(buf + 1, packet_time);
|
|
||||||
sub->end_display_time = parse_timecode(buf + 14, packet_time);
|
sub->start_display_time = start_display_time = parse_timecode(buf + 1, packet_time);
|
||||||
|
sub->end_display_time = end_display_time = parse_timecode(buf + 14, packet_time);
|
||||||
|
if (sub->start_display_time != start_display_time ||
|
||||||
|
sub-> end_display_time != end_display_time) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "time code not representable in 32bit\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
buf += 27;
|
buf += 27;
|
||||||
|
|
||||||
// read header
|
// read header
|
||||||
|
Loading…
x
Reference in New Issue
Block a user