From patchwork Thu Jun 20 19:35:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 50025 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:ae71:0:b0:482:c625:d099 with SMTP id w17csp103579vqz; Thu, 20 Jun 2024 12:35:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWeWD1eA8V2bxe+PQ4IeL9RsZFTKhMpfJK3RiLksV7hi6uu+eb1inXmaTPFTLMsDyP5GqnYLn+Vt7EaA14rzHGF+5ZzBpcQB8GHfQ== X-Google-Smtp-Source: AGHT+IFpk/i9Rte3lFIzLaQ7O5UmSm7s/E+HJRC5PNYBfUGfSDCQjK7ZFwOOMhjiM8q+MjgHg3zP X-Received: by 2002:a05:651c:1057:b0:2eb:fcd0:5192 with SMTP id 38308e7fff4ca-2ec3cea1063mr43626251fa.23.1718912149794; Thu, 20 Jun 2024 12:35:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718912149; cv=none; d=google.com; s=arc-20160816; b=gPUt7U68C/2lgBnTwcpUkSyKTqS3m2w/xhChZaZRXE7f0vtZ9/+fYPUxJZ01p10Fgr i4PiIf5t4Fg/azLmDnfjiAGCdJCR8AjTgeqOJ3+3I3p6Rui6Ja+hjsaIejFsfOfhwa7A d7OlmJrMBci5Pap99OdnPo7ZlBQy4ngNHWxgw+4cgY8ejbVtmNwReVoR1m/VcYF7m1U3 UL05ESOAKROzt7+WCCkA4lxIciUOITQOfTGCyc32SGo5oTEIR2b89eR5MCgFs+xl5gKe lnDPDCNJeorCIgiNzDyN0e3e+/JCpmRl/N0VDXahvIyvRBSLlT9T9zQw1JKOb5dFCz50 gIiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=EGvFL8xgqfAD3EMvvpInhXk6H4v4oowuGLl5MfLGndA=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=CzdcCNsHK/Wr2gAN8zZj2T0ra44fx/y3QrfMa56fJawdusqGyFc54tJHWdYcHsF5QO JB+3wAtz5dIgQilIycCAtyYtI8BcEKzrziPGO1WABxFhq9CCc3SlVTvqD7Q6y+6/VB5v BcMe7Es8S5DExJRcziyKCeYtJv9w6jYFW/cbac+iOrOUPmxQyc8xmVS13R31IogLG3OK YyGQ6VL4H0dZp8gIfB8XP0mgM+cWt8bhuFp3tQwgaLpvHSRsO31HuufIVMOqQswBRd8Z TLBNMO1QXunU8c5/j2B3+KfsuN7GVcKqXc2wYWB87CBgW4YHzQz94ANcip9R/gDL5qgm fQAg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=eDYNVhR7; 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 4fb4d7f45d1cf-57d0781ed69si2017498a12.343.2024.06.20.12.35.48; Thu, 20 Jun 2024 12:35:49 -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; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=eDYNVhR7; 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 925D468D8A6; Thu, 20 Jun 2024 22:35:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5DDBD68D88B for ; Thu, 20 Jun 2024 22:35:09 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 98CB2240002 for ; Thu, 20 Jun 2024 19:35:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1718912108; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tRo22XWi7HkvzLPqkQdUMtcuenh6914M8KbqR6VkX+s=; b=eDYNVhR7aOVVg0IMIvmpRers2VdMoPwb0/098/4o4WNGP5kpTm9cI9mbRKcQc6AkY/LvgQ JazvLa7Qh4H5m7cf0ca3VSwZcBtrkpUUXjkhAStbrs/dbwxdnd+pH+d0E3zRQVsjk2I1WH h1xBv8YUBFo4JTPlAI2Hvw+qz/R7P1U5aGz7HX5PmQFJiSOzNRPeiMeWqWU8GW2Atf8gIi mWIyEqhhznYkvihBZ53t7TRe//ZqJh7NVUfDOm1xIqFOKvl05PS0qA95ZfXUf7Lby+ys/1 OPC5NoyZOlp4Hd2OAp4eb3o7cCow1J0m9UGqlCjNMs4EShll1Slpl9OY176PLA== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 20 Jun 2024 21:35:04 +0200 Message-ID: <20240620193504.2310780-4-michael@niedermayer.cc> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240620193504.2310780-1-michael@niedermayer.cc> References: <20240620193504.2310780-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 4/4] avcodec/mpegvideo_enc: Do not duplicate pictures on shifting 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: /AJDMLKpOaFr Fixes: out of array access Fixes: 69098/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG2VIDEO_fuzzer-6107989688778752 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/mpegvideo_enc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index eda23056301..dc9a0009f53 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1266,6 +1266,8 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg) /* shift buffer entries */ for (int i = flush_offset; i <= MAX_B_FRAMES; i++) s->input_picture[i - flush_offset] = s->input_picture[i]; + for (int i = MAX_B_FRAMES + 1 - flush_offset; i <= MAX_B_FRAMES; i++) + s->input_picture[i] = NULL; s->input_picture[encoding_delay] = pic;