From patchwork Mon Sep 13 22:48:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 30221 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp4447301iov; Mon, 13 Sep 2021 15:55:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztOmTCYcOQphbTziluE7eNmJ7JBBPZfbN9slS2jpVLMxlG+gqwjq17eoFmlkWJyAEOn8L0 X-Received: by 2002:a17:906:1e0c:: with SMTP id g12mr15614844ejj.155.1631573746780; Mon, 13 Sep 2021 15:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631573746; cv=none; d=google.com; s=arc-20160816; b=fT/xQsFuQPWg2Mdjcpwycp1k9ZZL5QcoMtzf6S7oT0IgfrIozE9zrLE3VEZ1eCfgxN v5p5uyqgWD+15IELocLmjk0IgrenYCtiR30NkXWhX6AwgBt6pH80stZavBWSETimgsHM 30M48N+SlwZgwb7Hfq/Z8UMiVZE1jM3K6gu3qLwFwbsPS6zysgLSKpxrC8xipXzGcxNE LwUGSk0M0pcyi0pZTi8qWzjtHMXOtCSdJw2w3hFYl+Jz7uoqbkDRcarSChtdOfbK1LbD l2XG+nFUZNHF9bE4SjUaKb5pSizXkngBbvpZnwsdHKTmqocLtOoH52jMSQTfel0CAmyT XJIw== 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=cEY4N2CUF4VLn+saNCcZrrrHoRxebT8u6q73yhNRk6s=; b=EEdoJgl2mOBu8GpTEblZR0YazaBQrm+PGrNIvttetOpIXRBvvVsf0yTTPD3tpMgZoS Tkj6EADWu7xcTIw88vPBubJC79DjQxtMGn64c85iXPO2KSP6uymVXj5t/C1QNCGRJSY5 Wl+0BtG6baMUER1pfGy78jMPChYwCUYGa+enRWaJm3o4EhMx45GdAfR854YMhKyhMFJt DQVqZz/w60U48B07TPt6dufY6qQrBEGyZlG1KixpzkLx3BEoL01LZlki5hEUPAIkKnX4 MAcof30yu/vWW2qNSBMKW5oy19EUi5plaCTvzGSxv5lBgVBSLhlKw495TyuDjMiMHqdm vGTg== 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 f3si2339046edr.23.2021.09.13.15.55.46; Mon, 13 Sep 2021 15:55:46 -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 5B09768AEB5; Tue, 14 Sep 2021 01:55:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe02-2.mx.upcmail.net (vie01a-dmta-pe02-2.mx.upcmail.net [62.179.121.158]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 46DDA68A8F8 for ; Tue, 14 Sep 2021 01:55:37 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe02.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1mPulp-00CPJG-0H for ffmpeg-devel@ffmpeg.org; Tue, 14 Sep 2021 00:49:49 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id PukqmP98AljeHPukqmJNEo; Tue, 14 Sep 2021 00:48:48 +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.3 cv=BoHjPrf5 c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=nZOtpAppAAAA:20 a=vdV86qiOUNWwlnYB9J8A:9 a=1fhp2MxaeJtTNGEnv6mo:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 14 Sep 2021 00:48:46 +0200 Message-Id: <20210913224848.15336-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4wfD5erAe5McfWUQIGK8LmjCD90/XSSI2n+N+e/0KpmdHonVLTm9iFmyoxGu8Xs5maqLdUpc2hNabRLBW/l5krwvbmBqk3XsdLuYHmWLvY+5oywGaGoxkN tRrSOa61WW+Rfn43HxQuua5nGvN4TP1iAczHDe4pBxO0HeVj9z3J562H Subject: [FFmpeg-devel] [PATCH 1/3] avcodec/jpeg2000_parser: Check state!=0 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: cbescurKITiO Fixes: out of array read Fixes: 37664/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5893420460146688 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/jpeg2000_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/jpeg2000_parser.c b/libavcodec/jpeg2000_parser.c index e6db7eefa86..2975e71482a 100644 --- a/libavcodec/jpeg2000_parser.c +++ b/libavcodec/jpeg2000_parser.c @@ -142,7 +142,7 @@ static int find_frame_end(JPEG2000ParserContext *m, const uint8_t *buf, int buf_ m->in_codestream = 0; } else if (m->in_codestream && (state & 0xFFFF) == 0xFF90) { // Are we in tile part header? m->read_tp = 8; - } else if (pc->frame_start_found && info_marker((state & 0xFFFF0000)>>16) && m->in_codestream) { + } else if (pc->frame_start_found && info_marker((state & 0xFFFF0000)>>16) && m->in_codestream && (state & 0xFFFF)) { // Calculate number of bytes to skip to get to end of the next marker. m->skip_bytes = (state & 0xFFFF)-1;