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
834 int status;834 int status;
835 int mbmodetab, imvtab, icbptab, twomvbptab, fourmvbptab; /* useful only for debugging */835 int mbmodetab, imvtab, icbptab, twomvbptab, fourmvbptab; /* useful only for debugging */
836 int scale, shift, i; /* for initializing LUT for intensity compensation */836 int scale, shift, i; /* for initializing LUT for intensity compensation */
837 int field_mode, fcm;
837 838
838 v->numref=0;839 v->numref=0;
839 v->p_frame_skipped = 0;840 v->p_frame_skipped = 0;
@@ -848,19 +849,23 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) · 8 unmodified lines
848 goto parse_common_info;849 goto parse_common_info;
849 }850 }
850 851
851 v->field_mode = 0;852 field_mode = 0;
852 if (v->interlace) {853 if (v->interlace) {
853 v->fcm = decode012(gb);854 fcm = decode012(gb);
854 if (v->fcm) {855 if (fcm) {
855 if (v->fcm == ILACE_FIELD)856 if (fcm == ILACE_FIELD)
856 v->field_mode = 1;857 field_mode = 1;
857 if (!v->warn_interlaced++)858 if (!v->warn_interlaced++)
858 av_log(v->s.avctx, AV_LOG_ERROR,859 av_log(v->s.avctx, AV_LOG_ERROR,
859 "Interlaced frames/fields support is incomplete\n");860 "Interlaced frames/fields support is incomplete\n");
860 }861 }
861 } else {862 } else {
862 v->fcm = PROGRESSIVE;863 fcm = PROGRESSIVE;
863 }864 }
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;
864 869
865 if (v->field_mode) {870 if (v->field_mode) {
866 v->fptype = get_bits(gb, 3);871 v->fptype = get_bits(gb, 3);
libavcodec/vc1.h+1−0
@@ -368,6 +368,7 @@ typedef struct VC1Context{ · 367 unmodified lines
368 int qs_last; ///< if qpel has been used in the previous (tr.) picture368 int qs_last; ///< if qpel has been used in the previous (tr.) picture
369 int bmvtype;369 int bmvtype;
370 int frfd, brfd; ///< reference frame distance (forward or backward)370 int frfd, brfd; ///< reference frame distance (forward or backward)
371 int first_pic_header_flag;
371 int pic_header_flag;372 int pic_header_flag;
372 373
373 /** Frame decoding info for sprite modes */374 /** 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
5516 5516
5517 // do parse frame header5517 // do parse frame header
5518 v->pic_header_flag = 0;5518 v->pic_header_flag = 0;
5519 v->first_pic_header_flag = 1;
5519 if (v->profile < PROFILE_ADVANCED) {5520 if (v->profile < PROFILE_ADVANCED) {
5520 if (ff_vc1_parse_frame_header(v, &s->gb) < 0) {5521 if (ff_vc1_parse_frame_header(v, &s->gb) < 0) {
5521 goto err;5522 goto err;
@@ -5525,6 +5526,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, · 3 unmodified lines
5525 goto err;5526 goto err;
5526 }5527 }
5527 }5528 }
5529 v->first_pic_header_flag = 0;
5528 5530
5529 if (avctx->debug & FF_DEBUG_PICT_INFO)5531 if (avctx->debug & FF_DEBUG_PICT_INFO)
5530 av_log(v->s.avctx, AV_LOG_DEBUG, "pict_type: %c\n", av_get_picture_type_char(s->pict_type));5532 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