From patchwork Tue Aug 31 18:33:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 29930 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp5179969iov; Tue, 31 Aug 2021 11:40:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynNKh7o+UMLKGDxl1a9PheiGpMSwrcIavtopnBXAuSbpxzoQ8I+GpiWSq7W0RN3GuHTooB X-Received: by 2002:a50:f0d5:: with SMTP id a21mr17353930edm.244.1630435222680; Tue, 31 Aug 2021 11:40:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630435222; cv=none; d=google.com; s=arc-20160816; b=vn2qbuW2bdejQ3t571pnj2Ow1UVQddQQxhUsIQq2CqX3pUl0pWFLy/b2pJW7A1CgRz 9sjjII59wDJI/q5RYoJgljsJcY+16U09CK9uzgEIAbQ9Wy5buLsOCzg3WlJvIMO4DhzG zBd/jhdG+gl+ZVFV7B3Tq7eqmHaDa96MwCV/1X1G6hPJ0zE9lELuIl08xnHiqb3K0A8p loEyRYBDOts8xWrrSfwAvhGEmgbwDC3Dev7Wlfsbwdv+t8PWC0SnoiYerQbxQxdCrMin ysZbzcTgC3UMSQeuBqRL489KtLrP+GJjEmUuQ/arsscWteQWrtA9vMgmL8m/Ubtqe67/ /cVw== 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=Vie94OqPuwmf3hqNRpW7OD1nfm0iJ38/p+sXkjiypG0=; b=QB24kEoRyRYnI2DKrrPSLvb8NmxKayI9sXZ87WDniltPFMydYe5qDg+SEN3gLkyKjS 25Gd4/QVK7/MJ9KPEaR62R6TUo45RW+OAoDERVq+3agk4MyGOhumfvJrdMUywV83wIes KCgYmush1bqgY9Ha6NtjnITW+JJIRDAvojQU9BzbwlKLZozhtWERiCaQ5K+caKeQUupZ /7zcpOtgyNLGrSYZoCMHN8HGoiEhn65+m98VI/29dhhQFYWeqMQH8JvJx+RMQPwfDHPq sWlhjKC8x1Nz1OAWf4WmhGm1/Qg3yo3f6P53NHel/zV1nbN1en3AzyADtNos/dlPvYR4 mxSQ== 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 k5si279211edr.133.2021.08.31.11.40.22; Tue, 31 Aug 2021 11:40:22 -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 0B5B868A2D2; Tue, 31 Aug 2021 21:40:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe03-2.mx.upcmail.net (vie01a-dmta-pe03-2.mx.upcmail.net [62.179.121.161]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EC05C6809E0 for ; Tue, 31 Aug 2021 21:40:13 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1mL8ap-008jZW-0G for ffmpeg-devel@ffmpeg.org; Tue, 31 Aug 2021 20:34:43 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id L8ZqmkqkUljeHL8ZqmplUR; Tue, 31 Aug 2021 20:33:43 +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=my47eFXueJ_DgFcvEyIA:9 a=1fhp2MxaeJtTNGEnv6mo:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 31 Aug 2021 20:33:41 +0200 Message-Id: <20210831183342.3268-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4wfCnuU8m8uWbgWExa5TzjbyJBcWyjEwmveZ63JSFsaXEFR/JLxV7zTEPLSeupgkeQgE3nCrbFLKVu65kJWodif6BVtsPLOBo3blauDYGE+5t0A09qTIe0 AEC2O4OmJ3of9sPZg7645aeAp9Pqvq3DCTqENKDXkxF+6wYe6eHw44BC Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/pictordec: Optimize more odd cases for picmemset() 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: AWCiJljmcN5C Fixes: Timeout Fixes: 36875/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PICTOR_fuzzer-4842960888922112 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/pictordec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c index c37c5e7106..c7b3a335d3 100644 --- a/libavcodec/pictordec.c +++ b/libavcodec/pictordec.c @@ -89,8 +89,7 @@ static void picmemset(PicContext *s, AVFrame *frame, unsigned value, int run, d = frame->data[0] + yl * frame->linesize[0]; if (s->nb_planes == 1 && run*pixels_per_value >= s->width && - pixels_per_value < s->width && - s->width % pixels_per_value == 0 + pixels_per_value < (s->width / pixels_per_value * pixels_per_value) ) { for (; xl < pixels_per_value; xl ++) { j = (j < bits_per_plane ? 8 : j) - bits_per_plane; @@ -98,7 +97,7 @@ static void picmemset(PicContext *s, AVFrame *frame, unsigned value, int run, } av_memcpy_backptr(d+xl, pixels_per_value, s->width - xl); run -= s->width / pixels_per_value; - xl = s->width; + xl = s->width / pixels_per_value * pixels_per_value; } } } From patchwork Tue Aug 31 18:33:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 29931 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp5180079iov; Tue, 31 Aug 2021 11:40:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfqZ5W9lCLumIe6oYlQiUZSdSkb6cSGlOPdyrxIixYJmLFMeMirBPxoGT5tKZNeRUFNcre X-Received: by 2002:a05:6402:2801:: with SMTP id h1mr31063318ede.209.1630435232790; Tue, 31 Aug 2021 11:40:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630435232; cv=none; d=google.com; s=arc-20160816; b=XaYGpxh9QTq5xS0XmSGK2jhDs547H8Hed3uX9+3KUCK/kl/kVa8sbV9OgyAUAAVHCD LW411KEE9qe0x31ADQ85ux6wx6mtdckaywlpu84/g+NNU6bdecoFcnh3Gp1T/rxjitkC R/jx2ag2iK1TbVEPT9X0M9kbLZZ5P3y5o3q1lJuUXN7ZVluMO6K66r1wPfLDpid1vPCZ HdziOqxK4I/HA+e+uo++txZR2DL5JcqJDTNX6QS6ianTkQajJjNBlVH/OtgHWlvDp7/j qgrvckKol2FdFQCfTHKFmc0Wd+LdtsQrlXWSENqsFgQbibaKEKzy2Fi2vrXowzavFuHo VsxA== 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=7a9pFs6a7KW6HyoUZ1ps4DCIUG142irn3aJa4gelFZ0=; b=xuxWTIJONI9keOks1is0E13uhKD8aVwe+5GbbNnoVu0moyBZAYIyfKlSNTORtIBqLb 77fAzM8MwbSdwkqG+b1DrRTHM5CQQcmroJAbCd28rpz6pObsv2GSTLuKGSsrmUhw9Hvq IJTrls5PaJiCIUaOw2Fg+yhfp7i4ghN2Qz5SNcFUtY8+owiZbP4zBHJ1uZOXsVvBa+Fz miiGqoCh1Twk3558BkfwKSLMHA0cFHTAA+5orcfgdpmZRgaxMBNwM0NpTaQ5duxhi3KP 7Iu+YbvPvOamWNfvkel60tBEaLgW5jORcG0z+rcH25UEObJJljwmBBiDTXnL1jN5yG4l aAoA== 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 ca20si18139078edb.178.2021.08.31.11.40.32; Tue, 31 Aug 2021 11:40: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 0F16B68A41C; Tue, 31 Aug 2021 21:40:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe03-2.mx.upcmail.net (vie01a-dmta-pe03-2.mx.upcmail.net [62.179.121.161]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 082E868A3F4 for ; Tue, 31 Aug 2021 21:40:22 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1mL8ap-008k6S-0G for ffmpeg-devel@ffmpeg.org; Tue, 31 Aug 2021 20:34:43 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id L8ZrmkqlvljeHL8ZrmplVV; Tue, 31 Aug 2021 20:33:43 +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=54hVXT9OsABNOZ4ahBQA:9 a=1fhp2MxaeJtTNGEnv6mo:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 31 Aug 2021 20:33:42 +0200 Message-Id: <20210831183342.3268-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210831183342.3268-1-michael@niedermayer.cc> References: <20210831183342.3268-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfCnuU8m8uWbgWExa5TzjbyJBcWyjEwmveZ63JSFsaXEFR/JLxV7zTEPLSeupgkeQgE3nCrbFLKVu65kJWodif6BVtsPLOBo3blauDYGE+5t0A09qTIe0 AEC2O4OmJ3of9sPZg7645aeAp9Pqvq3DCTqENKDXkxF+6wYe6eHw44BC Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/mpeg12dec: Do not put mpeg_f_code into an invalid state on error return 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: sR+vI6yZXwaq Fixes: invalid shift Fixes: 37018/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG2VIDEO_fuzzer-5290280902328320 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/mpeg12dec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 49d865853b..507a271073 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -1538,6 +1538,10 @@ static int mpeg_decode_picture_coding_extension(Mpeg1Context *s1) s->mpeg_f_code[0][1] = get_bits(&s->gb, 4); s->mpeg_f_code[1][0] = get_bits(&s->gb, 4); s->mpeg_f_code[1][1] = get_bits(&s->gb, 4); + s->mpeg_f_code[0][0] += !s->mpeg_f_code[0][0]; + s->mpeg_f_code[0][1] += !s->mpeg_f_code[0][1]; + s->mpeg_f_code[1][0] += !s->mpeg_f_code[1][0]; + s->mpeg_f_code[1][1] += !s->mpeg_f_code[1][1]; if (!s->pict_type && s1->mpeg_enc_ctx_allocated) { av_log(s->avctx, AV_LOG_ERROR, "Missing picture start code\n"); if (s->avctx->err_recognition & AV_EF_EXPLODE) @@ -1553,10 +1557,6 @@ static int mpeg_decode_picture_coding_extension(Mpeg1Context *s1) s->current_picture.f->pict_type = s->pict_type; s->current_picture.f->key_frame = s->pict_type == AV_PICTURE_TYPE_I; } - s->mpeg_f_code[0][0] += !s->mpeg_f_code[0][0]; - s->mpeg_f_code[0][1] += !s->mpeg_f_code[0][1]; - s->mpeg_f_code[1][0] += !s->mpeg_f_code[1][0]; - s->mpeg_f_code[1][1] += !s->mpeg_f_code[1][1]; s->intra_dc_precision = get_bits(&s->gb, 2); s->picture_structure = get_bits(&s->gb, 2);