ffmpeg/CVE-2021-38114.patch
yangweidong 27cf41fbb6 fix CVE-2021-38114 CVE-2020-35964
(cherry picked from commit 6ee873138691521c281babf0daf900f2a5a6f45b)
2022-06-10 16:41:46 +08:00

46 lines
1.7 KiB
Diff

diff -Naru ffmpeg-4.2.4/libavcodec/dnxhddec.c ffmpeg-4.2.4-new/libavcodec/dnxhddec.c
--- ffmpeg-4.2.4/libavcodec/dnxhddec.c 2022-05-24 10:57:19.937425000 +0800
+++ ffmpeg-4.2.4-new/libavcodec/dnxhddec.c 2022-05-24 10:59:49.141810000 +0800
@@ -111,6 +111,7 @@
static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid, int bitdepth)
{
+ int ret;
if (cid != ctx->cid) {
int index;
@@ -130,19 +131,26 @@
ff_free_vlc(&ctx->dc_vlc);
ff_free_vlc(&ctx->run_vlc);
- init_vlc(&ctx->ac_vlc, DNXHD_VLC_BITS, 257,
+ if ((ret = init_vlc(&ctx->ac_vlc, DNXHD_VLC_BITS, 257,
ctx->cid_table->ac_bits, 1, 1,
- ctx->cid_table->ac_codes, 2, 2, 0);
- init_vlc(&ctx->dc_vlc, DNXHD_DC_VLC_BITS, bitdepth > 8 ? 14 : 12,
+ ctx->cid_table->ac_codes, 2, 2, 0)) < 0)
+ goto out;
+ if ((ret = init_vlc(&ctx->dc_vlc, DNXHD_DC_VLC_BITS, bitdepth > 8 ? 14 : 12,
ctx->cid_table->dc_bits, 1, 1,
- ctx->cid_table->dc_codes, 1, 1, 0);
- init_vlc(&ctx->run_vlc, DNXHD_VLC_BITS, 62,
+ ctx->cid_table->dc_codes, 1, 1, 0)) < 0)
+ goto out;
+ if ((ret = init_vlc(&ctx->run_vlc, DNXHD_VLC_BITS, 62,
ctx->cid_table->run_bits, 1, 1,
- ctx->cid_table->run_codes, 2, 2, 0);
+ ctx->cid_table->run_codes, 2, 2, 0)) < 0)
+ goto out;
ctx->cid = cid;
}
- return 0;
+ ret = 0;
+out:
+ if (ret < 0)
+ av_log(ctx->avctx, AV_LOG_ERROR, "init_vlc failed\n");
+ return ret;
}
static av_cold int dnxhd_decode_init_thread_copy(AVCodecContext *avctx)