1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

flicvideo: check extradata_size before accessing extradata.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
This commit is contained in:
Carl Eugen Hoyos 2011-11-09 14:04:22 +01:00 committed by Anton Khirnov
parent 5ace144fe0
commit 1484b5dec5

View File

@ -81,6 +81,12 @@ static av_cold int flic_decode_init(AVCodecContext *avctx)
unsigned char *fli_header = (unsigned char *)avctx->extradata; unsigned char *fli_header = (unsigned char *)avctx->extradata;
int depth; int depth;
if (avctx->extradata_size != 12 &&
avctx->extradata_size != 128) {
av_log(avctx, AV_LOG_ERROR, "Expected extradata of 12 or 128 bytes\n");
return AVERROR_INVALIDDATA;
}
s->avctx = avctx; s->avctx = avctx;
s->fli_type = AV_RL16(&fli_header[4]); /* Might be overridden if a Magic Carpet FLC */ s->fli_type = AV_RL16(&fli_header[4]); /* Might be overridden if a Magic Carpet FLC */
@ -90,9 +96,6 @@ static av_cold int flic_decode_init(AVCodecContext *avctx)
/* special case for magic carpet FLIs */ /* special case for magic carpet FLIs */
s->fli_type = FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE; s->fli_type = FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE;
depth = 8; depth = 8;
} else if (s->avctx->extradata_size != 128) {
av_log(avctx, AV_LOG_ERROR, "Expected extradata of 12 or 128 bytes\n");
return -1;
} else { } else {
depth = AV_RL16(&fli_header[12]); depth = AV_RL16(&fli_header[12]);
} }