History

vc1dec: do not allow field_mode to change after the first header

Fixes out of array accesses.

Michael Niedermayer committed 14 years ago

Commit 7845f8d1 parent 8f42b093 files · +14 −6Browse files

Unified · Split

3 files
  1. libavcodec/vc1.c +11 −6
  2. libavcodec/vc1.h +1 −0
  3. libavcodec/vc1dec.c +2 −0
libavcodec/vc1.c+11−6
@@ -834,6 +834,7 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) · 833 unmodified lines
834834 int status;
835835 int mbmodetab, imvtab, icbptab, twomvbptab, fourmvbptab; /* useful only for debugging */
836836 int scale, shift, i; /* for initializing LUT for intensity compensation */
837+ int field_mode, fcm;
837838
838839 v->numref=0;
839840 v->p_frame_skipped = 0;
@@ -848,19 +849,23 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) · 8 unmodified lines
848849 goto parse_common_info;
849850 }
850851
851− v->field_mode = 0;
852+ field_mode = 0;
852853 if (v->interlace) {
853− v->fcm = decode012(gb);
854− if (v->fcm) {
855− if (v->fcm == ILACE_FIELD)
856− v->field_mode = 1;
854+ fcm = decode012(gb);
855+ if (fcm) {
856+ if (fcm == ILACE_FIELD)
857+ field_mode = 1;
857858 if (!v->warn_interlaced++)
858859 av_log(v->s.avctx, AV_LOG_ERROR,
859860 "Interlaced frames/fields support is incomplete\n");
860861 }
861862 } else {
862− v->fcm = PROGRESSIVE;
863+ fcm = PROGRESSIVE;
863864 }
865+ if (!v->first_pic_header_flag && v->field_mode != field_mode)
866+ return -1;
867+ v->field_mode = field_mode;
868+ v->fcm = fcm;
864869
865870 if (v->field_mode) {
866871 v->fptype = get_bits(gb, 3);
libavcodec/vc1.h+1−0
@@ -368,6 +368,7 @@ typedef struct VC1Context{ · 367 unmodified lines
368368 int qs_last; ///< if qpel has been used in the previous (tr.) picture
369369 int bmvtype;
370370 int frfd, brfd; ///< reference frame distance (forward or backward)
371+ int first_pic_header_flag;
371372 int pic_header_flag;
372373
373374 /** Frame decoding info for sprite modes */
libavcodec/vc1dec.c+2−0
@@ -5516,6 +5516,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, · 5515 unmodified lines
55165516
55175517 // do parse frame header
55185518 v->pic_header_flag = 0;
5519+ v->first_pic_header_flag = 1;
55195520 if (v->profile < PROFILE_ADVANCED) {
55205521 if (ff_vc1_parse_frame_header(v, &s->gb) < 0) {
55215522 goto err;
@@ -5525,6 +5526,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, · 3 unmodified lines
55255526 goto err;
55265527 }
55275528 }
5529+ v->first_pic_header_flag = 0;
55285530
55295531 if (avctx->debug & FF_DEBUG_PICT_INFO)
55305532 av_log(v->s.avctx, AV_LOG_DEBUG, "pict_type: %c\n", av_get_picture_type_char(s->pict_type));

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