comparison utils.c @ 10229:bd1c4a438c7f libavcodec

Check codec_id and codec_type in avcodec_open(), based on 43_codec_type_mismatch.patch from chrome This is said to be able to lead to a stack based buffer overflow.
author michael
date Tue, 22 Sep 2009 22:44:56 +0000
parents 1b2ef85867a9
children b81ec4ac8f96
comparison
equal deleted inserted replaced
10228:b783894a1c62 10229:bd1c4a438c7f
479 ret = AVERROR(EINVAL); 479 ret = AVERROR(EINVAL);
480 goto end; 480 goto end;
481 } 481 }
482 482
483 avctx->codec = codec; 483 avctx->codec = codec;
484 avctx->codec_id = codec->id; 484 if(avctx->codec_id != codec->id || avctx->codec_type != codec->type){
485 av_log(avctx, AV_LOG_ERROR, "codec type or id mismatches\n");
486 goto end;
487 }
485 avctx->frame_number = 0; 488 avctx->frame_number = 0;
486 if(avctx->codec->init){ 489 if(avctx->codec->init){
487 ret = avctx->codec->init(avctx); 490 ret = avctx->codec->init(avctx);
488 if (ret < 0) { 491 if (ret < 0) {
489 av_freep(&avctx->priv_data); 492 av_freep(&avctx->priv_data);