From patchwork Sat Sep 15 00:08:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 10330 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:12c4:0:0:0:0:0 with SMTP id 65-v6csp1156372jap; Fri, 14 Sep 2018 17:09:32 -0700 (PDT) X-Google-Smtp-Source: ANB0VdahJ7H08DPzGx2SYUzCIkzREgguWkbuZLim7SW6edJq9FXQlafI6X1QcWiD+sjibGuPovGX X-Received: by 2002:a1c:8b54:: with SMTP id n81-v6mr3781774wmd.142.1536970172349; Fri, 14 Sep 2018 17:09:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536970172; cv=none; d=google.com; s=arc-20160816; b=ukx0hwsBojgwXobdN2d1CsN+0Zohe3eP2AXbOCKO950PSVzZEdFKBvV+G0LRdWUWBK +AgmBlMALoGC52zjn5jTCmervny8t7/wDB6jn2c2zMrD16ch4ggaEV3zTNkYBlhdy3B6 8aVqnEOEQQFURmheo/wRdqnZUJaJ/SJbf1qTy1gOugWB3ik+HeZdV0R6bsluCurqprf2 A1o4VUt6mjnxhD3nCZyBYM0MxPRAVOGXKYk1U3sAjsY+60Vpm/EG5ZjaE7BPPHe62Sn8 auzNVb9Tw8ANWCLzP/Z0AfhuAEqkcKpyd+EEHNCnQWeOs7tjWZYTbg5IKEjrGuoJ51tt 0vlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=vdKBDARswWP+enN9mhldFbztgn5wKlxxzVRL0xKlFT4=; b=RnLRIOM3qrMLnP1eF8x7X7jQZW9XmKN32jumqkJPK66VXXKy071p2RVLnSsRu1KCqq odSPsibKjBI/0l6OmmegjeieJBk9PQ6p3gHer2/xPr9FRPYo8fQ1PwtmQ9yIXnmyTM3y O+jXkalc/v0KvSSMhuv9zR37K6ECeutBAZ/tVZvT/lZ8G7KMVNAqysVfJoJmNRtEOqVb +5zWRH3N2vTdJGK54ZwHJOQDyOBhcfeaInFIhpUuYSsnBOSD5Tlp4jRK/XZ/s1idtE3G ee0gI4iapvJeQ4HG1KX9fDUbnSFSMzSX8Ty9pzfyFd+c98KEmuqd5nh6CKQGhSBw2bBP kmBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j8-v6si7628902wrv.9.2018.09.14.17.09.31; Fri, 14 Sep 2018 17:09:32 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E627168A6CB; Sat, 15 Sep 2018 03:09:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe04-3.mx.upcmail.net (unknown [62.179.121.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C6B6468A68B for ; Sat, 15 Sep 2018 03:08:57 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe04.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1g0y97-0000YK-4j for ffmpeg-devel@ffmpeg.org; Sat, 15 Sep 2018 02:09:09 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id bc911y0060S5wYM01c92Vl; Sat, 15 Sep 2018 02:09:02 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 15 Sep 2018 02:08:21 +0200 Message-Id: <20180915000822.1017-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180915000822.1017-1-michael@niedermayer.cc> References: <20180915000822.1017-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/mpeg4videodec: Check rice_prefix_code X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes: out of array read Fixes: 10064/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-5766801384800256 Fixes: 10225/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-5071833448054784 Fixes: 10261/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-5115048024866816 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/mpeg4videodec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 4c77081237..853c6d9132 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -1968,6 +1968,10 @@ static int mpeg4_decode_dpcm_macroblock(MpegEncContext *s, int16_t macroblock[25 if (rice_prefix_code == 11) dpcm_residual = get_bits(&s->gb, s->avctx->bits_per_raw_sample); else { + if (rice_prefix_code == 12) { + av_log(s->avctx, AV_LOG_ERROR, "Forbidden rice_prefix_code\n"); + return AVERROR_INVALIDDATA; + } rice_suffix_code = get_bitsz(&s->gb, rice_parameter); dpcm_residual = (rice_prefix_code << rice_parameter) + rice_suffix_code; }