History

avcodec: Ignoring errors is only possible before the input end

Fixes: out of array read Fixes: Ticket 10308

Michael Niedermayer committed 3 years ago

Commit fead6561 parent 8e21f322 files · +3 −3Browse files

Unified · Split

2 files
  1. libavcodec/h263dec.c +1 −1
  2. libavcodec/mpeg4videodec.c +2 −2
libavcodec/h263dec.c+1−1
@@ -281,7 +281,7 @@ static int decode_slice(MpegEncContext *s) · 280 unmodified lines
281281 ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
282282 s->mb_x, s->mb_y, ER_MB_ERROR & part_mask);
283283
284− if (s->avctx->err_recognition & AV_EF_IGNORE_ERR)
284+ if ((s->avctx->err_recognition & AV_EF_IGNORE_ERR) && get_bits_left(&s->gb) > 0)
285285 continue;
286286 return AVERROR_INVALIDDATA;
287287 }
libavcodec/mpeg4videodec.c+2−2
@@ -1437,7 +1437,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block, · 1436 unmodified lines
14371437 if (SHOW_UBITS(re, &s->gb, 1) == 0) {
14381438 av_log(s->avctx, AV_LOG_ERROR,
14391439 "1. marker bit missing in 3. esc\n");
1440− if (!(s->avctx->err_recognition & AV_EF_IGNORE_ERR))
1440+ if (!(s->avctx->err_recognition & AV_EF_IGNORE_ERR) || get_bits_left(&s->gb) <= 0)
14411441 return AVERROR_INVALIDDATA;
14421442 }
14431443 SKIP_CACHE(re, &s->gb, 1);
@@ -1448,7 +1448,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block, · 4 unmodified lines
14481448 if (SHOW_UBITS(re, &s->gb, 1) == 0) {
14491449 av_log(s->avctx, AV_LOG_ERROR,
14501450 "2. marker bit missing in 3. esc\n");
1451− if (!(s->avctx->err_recognition & AV_EF_IGNORE_ERR))
1451+ if (!(s->avctx->err_recognition & AV_EF_IGNORE_ERR) || get_bits_left(&s->gb) <= 0)
14521452 return AVERROR_INVALIDDATA;
14531453 }
14541454

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t