From patchwork Thu Nov 25 19:30:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Alex Xu (Hello71)" X-Patchwork-Id: 31708 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp1238423iob; Thu, 25 Nov 2021 11:30:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPbFHOIq5JPY9y/D75teL+UPpG5oiUXUCGDIKbY4D04ZtsfPmatW1v3TcanadVFkVmqeD2 X-Received: by 2002:a17:907:3e8a:: with SMTP id hs10mr34142197ejc.404.1637868649449; Thu, 25 Nov 2021 11:30:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637868649; cv=none; d=google.com; s=arc-20160816; b=r+cbxdsMoW1x4Mank4PIBfk2WwTDU/Xvj2bSK9LVLHQV1hX4+hV7+HVhkGfmy9aTgW ZCiy35Ed3WFqddBvEwA7QajHEZ9SnNwFuoJE/q+51mt+3qJOhgYC4L7ZF5LB3p+JT35K Y9Y0NzCMJDJK+DQQ80m3txCcX6wPDvg/DxpotLaxEQigK5tKy+F15d1mtyqhdM9h+GME wIDsxkqXJUFM6HIKLBgp+OCKVmDvkwaUe7uYDBB3NoChgcq8WNFFyY0tLdt9kIteIiYo 5U1fhCO8Bz2zlbgUbFVvRFAain+/c3NjyBuvH9WDZ9f1K0rmuO7RtZf7FjV+v5+boPVD si2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:mime-version:message-id:date :to:from:dkim-signature:delivered-to; bh=7DKaFF2VC08Crzle+bvzQKtOL3Q3+lmeFWP1WUdfysM=; b=N5vd8Oc40H3/wGuGeDphjkm1fAffljw7usZX+uFCe8TAJrnAybKt8xnyK/07oy3Zn0 JN7m3RlRUKnV+kfocz1o5MuKRaFYB1Cso62gjPIfUW1KGdI6KJy6nf1D824YUBYewZjc GeIF2Ck51bOHuyhcXAF2rzIJvqTZjBrk1IpJDY+n4DpyCXggUUk6OaUoruwCIGXRW5ap SbLjWleJnuHeaWYhm6NV1DOwtBC6kuE6XC325W8WH8YKjP63W18yxLS23k3q8I/WwO+P dVPFq6K7jhRiY4TBUPaqpBiAcY6FM8tZnyQZrPmJdKoQOdnUT8wR3NORLPbVk57/jORO YILQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@yahoo.ca header.s=s2048 header.b=q8zElhlV; 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 i4si6699088ejz.261.2021.11.25.11.30.47; Thu, 25 Nov 2021 11:30:49 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@yahoo.ca header.s=s2048 header.b=q8zElhlV; 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 8C40568ACFD; Thu, 25 Nov 2021 21:30:21 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from sonic305-20.consmr.mail.gq1.yahoo.com (sonic305-20.consmr.mail.gq1.yahoo.com [98.137.64.83]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C6DFD68A718 for ; Thu, 25 Nov 2021 21:30:13 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.ca; s=s2048; t=1637868610; bh=DY9w4HXeqxsAdgVaFi1bAyqNFgq0kWqPfsUBCCWixOM=; h=From:To:Cc:Subject:Date:References:From:Subject:Reply-To; b=q8zElhlVI/plwCynTi2RO6HHETrmcFTM1HgZr/Nugzp/ntoXjsaQx+RQpTf3naXxTT3eAZd+9HfcICc09MO+WN65nq4zj9yBj/0kxnphJHaFVxFHihFh8ETRQg11kiZfFiWerlOfKhZpnKAQA9L5OAWxVSgU1w4iXXXCjMhtVZyk+moEqV6JOwQOaDP8ARdmH4Q71+6eaqhXR0K0ob/ReuHw57El+0+Wic7+EDKNbMK7rHWdFoMm3wzytrtQUlbTeG5rQF+NoFuVbmIIJMtoAZSC2BDUfeecAeRBF1CA+2WhIEGwcXvovWcQuOAzHIJuH3CgHx2jRvFaHU+ltOjmpg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1637868610; bh=TsoHWuPx6IjlhY9PDki1ZJFNQgQ32oP4/diaDvRKoI3=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=XHxTmMRpFzTch4xPScPAmTtWOumPhWXug0vcdB6ivqWY0nTnhLXUueDLH6RG9j/nsxQS24w1Oc3wkv+hHrDhRE4p4P4W/phiwcVFgkdTeaFyi+MqAxIyis1ZZYuYWu/WlwqbuQ5Awqzuejoqyun6baUd9Ki6qfVveiT2OCzpyQcfLN7VbVWgTTuXAc1d+mk1luWn+bF488PTbIiGbH+qVKMM3K2DBuQFaP/ZNoUfz8HtlitCxGhEOmnMUKwEYe/0XJlbMv3zCN0ftfaUz7pAg/t+Q9jivQVCm8dNXKdxCgH73+CkBNqGRE7FmpVlxRqAefutbKawDqFKHKsRzILsnA== X-YMail-OSG: lvEGoPgVM1mOff06HE4pXRlQ_LiBohNlg_Aerj4T0QtQxozZ.5pEhCelN6uBDX6 brztzDZjZf35DwHN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CMgiB_hsyIcYr_dlPGp8h8WPLYnwx3LOCFrDBCCV.9X6IFkq L8sojmBpJEziVSlyYT2Jn0ElnazDLGwchEDZHxek.NhUElECHzgQ9flSsocXf X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.gq1.yahoo.com with HTTP; Thu, 25 Nov 2021 19:30:10 +0000 Received: by kubenode517.mail-prod1.omega.gq1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 44ad0422e733e1cbf5b2e8c0bde876c5; Thu, 25 Nov 2021 19:30:08 +0000 (UTC) From: "Alex Xu (Hello71)" To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Nov 2021 14:30:33 -0500 Message-Id: <20211125193034.8061-1-alex_y_xu@yahoo.ca> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 References: <20211125193034.8061-1-alex_y_xu.ref@yahoo.ca> Subject: [FFmpeg-devel] [PATCH] avcodec/mjpeg_parser: skip markers after EOI, not by size 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 Cc: "Alex Xu \(Hello71\)" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: /0Tf+FFEAB0R The check for m->size >= 0xF000 is intended to avoid skipping too much garbage data between JPEG frames in test_roman (thus missing next SOI), but it erroneously also skips valid markers between SOI and SOS. Instead of this, we should simply skip parsing markers other than SOI after EOI. That way, we will not accidentally skip over SOI due to some garbage between frames. There is still a small risk of encountering FFD8 in the garbage data, but the chance of this is fairly low. Fixes: https://trac.ffmpeg.org/ticket/8967 --- libavcodec/mjpeg_parser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/mjpeg_parser.c b/libavcodec/mjpeg_parser.c index 16a5902c7c..62b923b625 100644 --- a/libavcodec/mjpeg_parser.c +++ b/libavcodec/mjpeg_parser.c @@ -80,10 +80,10 @@ static int find_frame_end(MJPEGParserContext *m, const uint8_t *buf, int buf_siz pc->frame_start_found=0; pc->state=0; return i-3; + } else if((state>>16)==0xFFD9 && (state&0xFFFF)!=0xFFD8){ + state= 0xFFD900|(state&0xFF); } else if(state<0xFFD00000 || state>0xFFD9FFFF){ m->size= (state&0xFFFF)-1; - if (m->size >= 0xF000) - m->size = 0; } } if(m->size>0){