From patchwork Sun Sep 18 21:57:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 38037 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp886009pzh; Sun, 18 Sep 2022 14:57:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6VEm7OGqHs0qqqSQZOAnoM2WkX92eF5Zp/LyGipKDfpwWiHKgysYQVMYkgNA/yG9pAYfgQ X-Received: by 2002:a17:907:3201:b0:741:94f2:aeaf with SMTP id xg1-20020a170907320100b0074194f2aeafmr10409616ejb.505.1663538237634; Sun, 18 Sep 2022 14:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663538237; cv=none; d=google.com; s=arc-20160816; b=oXdelMc3CaJIqUVMtKuELgvOZBkXvLmtDP9SDKmtyC3srrJ2FmJ0V09dyLPgP0Png0 SZLxhSbxdySKQ0T0mTsuuZRcNk5BeUKntcBic54G3A00L888CGM6c5KokWUPszXMgcBe 6nwAXBVx4BEmCHauu2aZ2Hrff13vF0yxDqMkRis7kvYCsASk94NF3kZblzLE1kNjphXs JmcP0WUyNVdQy4/NEkG290wKjkzYoJCIXb3/ZTmtVxjs9npqnRv5wCBmeTfbjUCiWB8S FrUdXovskgxX+wpB9XwO3ZdgaHSw0HOLTmt2bdah92nLpW3gxi3yYDJG93/do2CkDwl0 7sFw== 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:message-id:date:to:from:delivered-to; bh=dS7B3gWM3NGNn+L/QSkZpqHFITgXIz3SgRYiW4q7uvA=; b=JU6G4zXSh+PynLzIjJkR9dhKsq/fOtXsZW868IPjb1azqKlygE0zsGtUoDwhxXjdvU CQ1v7Uc/SozEDmd/zrXBvZe5VSAPPNR3JQGy4n1IhbCcJziYPRs23SModTRTHLIIaQC9 t4X9xxs+NK2b1GnJUSktSH76vlZ6zsRIzi6qKoxW6X+tgc460DGqR5EmYypYLkALaXP8 Ix2Bw1Bl6ylxZ1aRhwF8FaABExIdRpkkQIIhMnC+Mw/cMUavKmt1xfzgVG8lQeN1JlxJ 6gzDtouDSNneFxiCgIbIy/pc2kTyBQKDRq4uNxSsyI4c9fk0XiEhsdv8Yahl+OTu4lLi zFzA== 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 y11-20020a056402134b00b0044eebb9818dsi7163802edw.456.2022.09.18.14.57.16; Sun, 18 Sep 2022 14:57:17 -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 A2C8968BBE5; Mon, 19 Sep 2022 00:57:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-at03-2.mx.upcmail.net (vie01a-dmta-at03-2.mx.upcmail.net [62.179.121.152]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DE9C168BB03 for ; Mon, 19 Sep 2022 00:57:06 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-at03.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1oa2Hh-00F0Id-GD for ffmpeg-devel@ffmpeg.org; Sun, 18 Sep 2022 23:57:05 +0200 Received: from ren-mail-psmtp-mg01. ([80.109.253.241]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id a2HgorDIN8s8Ua2HgoHb5X; Sun, 18 Sep 2022 23:57:05 +0200 Received: from localhost ([213.47.68.29]) by ren-mail-psmtp-mg01. with ESMTP id a2HgorOHbOG5Za2HgonZwm; Sun, 18 Sep 2022 23:57:04 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.4 cv=KJo5sHJo c=1 sm=1 tr=0 ts=63279430 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=NEAV23lmAAAA:8 a=3HKxcLYGzYoyLNpY0RQA:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 18 Sep 2022 23:57:03 +0200 Message-Id: <20220918215704.13793-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4wfNR263XhggeX0MaurcRqVxvvo/RsgulY2h2Z+wizLJF/7n6ftWO1pb2sAoUn0UOytq+j4Bx+8rENTN4NLQkjkqs9mEeNhA3SstSomugcIF+rlg0nSudL fiyE6N6AbIEoaYxPx2gTJa3pnr5xtQQmP49j+wMjNPMq10EJQxQVsXXIuoA07OqPYs15w230GNO4nw== Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/mjpegdec: Check for unsupported bayer case X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: /s5GTvtuZMpe Fixes: out of array access Fixes: 51462/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-662559341582745 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/mjpegdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 65337360b05..e0e1971715a 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -1212,6 +1212,8 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1]; } } else if (s->bayer) { + if (s->bits <= 8) + return AVERROR_PATCHWELCOME; if (nb_components == 1) { /* Leave decoding to the TIFF/DNG decoder (see comment in ff_mjpeg_decode_sof) */ for (mb_x = 0; mb_x < width; mb_x++)