From patchwork Thu Jun 8 17:18:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42016 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp564298pzb; Thu, 8 Jun 2023 10:18:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Apmyaq4nGWYmeDSh7T2ByAa6ygv3pk1RSUp3KmjdybHL/WaswRMDnKsLOJVbpqeEwLt2d X-Received: by 2002:a05:6402:1616:b0:514:224b:a48c with SMTP id f22-20020a056402161600b00514224ba48cmr3353454edv.0.1686244720157; Thu, 08 Jun 2023 10:18:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686244720; cv=none; d=google.com; s=arc-20160816; b=t9vMvEWN1fPaK5w0i0oIPPGX8QmodSkxAWkbY0ICfHcoWSNrAXUyP9min4UygGMWxr mKX9WMQPoDEX3Y0VD0/TlzWuVc6bSMEq8RTNa42ZO5DjHCvprNEnUSNtSb8KImQE2fds H6eINR5KWp017CF1rrIRpRXVw/BIKTOjV7HcTm98MCDrMW6iHv2+iyhyMFIms+EvQfub D3gBwtSjHhJukSZkFnkLSOky2P0VsIB+7jDrhjsRl7uFgUAA51eLGR6gMHrMwGBrqqoW ylCAcSopHdtv6AqcxEXBYcWLPfPolVFGha0S9pmUAboLL+GGhq1mnM3yphYHcZf8Sv5x /IOA== 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=6kDwBQjAVbHGgqQEiwSgJwQGmj+rQ/NpNK3lWa9gIOs=; b=iBI+QAFY3534HlCHYZMVACxT6S81g2RZqgLVvfMOx4LJyPX7TySYPL52D6asdDv2On 90uPDbnQtmKa9JKbZ8NeSb012Wvn2oEDldnJWhfAf/bpebSScVmvQtpusR64xwOI355F uCXh3u7VBOYJUi4+GXcn4O77DlDEUATmdaC/a6r4PeDcLb9aR3HKcWuOjA32zZu/39f0 eljMduKnPN5UaIiaiMyHv/zieGPUSbBwaDHG8izLrD5EQFhmwegqJ0UpOw73jMLOi6xg lX0V3jsVKtI99cCPltMbxM8NMPmJiTuRgz1/aIrSBKc/mpQS9uQDZ9PO+l843NH5ORZS gIDQ== 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 l6-20020aa7d946000000b00514b957c9dfsi1005320eds.571.2023.06.08.10.18.38; Thu, 08 Jun 2023 10:18:40 -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 AFC42689D6F; Thu, 8 Jun 2023 20:18:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-01-1.mymagenta.at (mail-01-1.mymagenta.at [80.109.253.246]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 18D22689D6F for ; Thu, 8 Jun 2023 20:18:28 +0300 (EEST) Received: from [192.168.232.136] (helo=ren-mail-psmtp-mg02.) by mail-01.mymagenta.at with esmtp (Exim 4.93) (envelope-from ) id 1q7JHG-003tgd-EE for ffmpeg-devel@ffmpeg.org; Thu, 08 Jun 2023 19:18:26 +0200 Received: from localhost ([84.115.40.24]) by ren-mail-psmtp-mg02. with ESMTP id 7JHHqT0jobZLD7JHHqqQSa; Thu, 08 Jun 2023 19:18:27 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 84.115.40.24 X-CNFS-Analysis: v=2.4 cv=Ufwy9IeN c=1 sm=1 tr=0 ts=64820d63 a=4thelYDX6rwh+ygQwvsI+Q==:117 a=4thelYDX6rwh+ygQwvsI+Q==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=NEAV23lmAAAA:8 a=oW1aMXZbcGzkY8OzWQ0A:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 8 Jun 2023 19:18:23 +0200 Message-Id: <20230608171825.6575-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4xfBuTGCQv6SrJKgXaiKifUTMah0QrL6FmLZS4OkmWSzKcWcvQQTDi2XzsDiPkko3PNhdwflK5zkrBwUXppJIsi9MPsXe1lOO3Lgp58b1s93FQy4+ygvYp yr3iRVxWdpLRrOABdKYTLSH6sJFXvwMKc/FCOXlafi++ErNYDAt3HjxIt8DkoA3tR3TX46x3hotULA== Subject: [FFmpeg-devel] [PATCH 1/3] avcodec/rka: use unsigned for buf0 additions 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: 8FV6pxdAAN4Z Fixes: signed integer overflow: -38912000 + -2109276160 cannot be represented in type 'int' Fixes: 59670/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-4987563245699072 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/rka.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/rka.c b/libavcodec/rka.c index 76dca52602..d56f4faee4 100644 --- a/libavcodec/rka.c +++ b/libavcodec/rka.c @@ -735,10 +735,10 @@ static int decode_filter(RKAContext *s, ChContext *ctx, ACoder *ac, int off, uns ctx->buf1[off] = (val + (sum >> bits)) * (1U << bits) + (((1U << bits) - 1U) & ctx->buf1[off + -1]); } - ctx->buf0[off] = ctx->buf1[off] + ctx->buf0[off + -1]; + ctx->buf0[off] = ctx->buf1[off] + (unsigned)ctx->buf0[off + -1]; } else { val *= 1U << ctx->cmode; - sum += ctx->buf0[off + -1] + val; + sum += ctx->buf0[off + -1] + (unsigned)val; switch (s->bps) { case 16: sum = av_clip_int16(sum); break; case 8: sum = av_clip_int8(sum); break; From patchwork Thu Jun 8 17:18:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42017 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp564405pzb; Thu, 8 Jun 2023 10:18:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ42t4VZprDQe12cDYwswDds8Xvy2z7CM5tNi+4AGjLA9EUeaoXgcKj5hn7+7DIcOKxkmMUI X-Received: by 2002:a17:907:9303:b0:973:daaa:f3e1 with SMTP id bu3-20020a170907930300b00973daaaf3e1mr406991ejc.39.1686244729631; Thu, 08 Jun 2023 10:18:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686244729; cv=none; d=google.com; s=arc-20160816; b=AR/+/xYhHWEks5gYAjnSBodBXQMaSTV9qD+qGK5j4uMYo9JEEqETh0/9cAHMLdLsdT QhreBWzCpb0TIBamJhVM4B+dRiNtIW1MR0Du8Nh7zf52xZ7yv5Y8rFJG2Nt26FMH9xCE NBFCw25RWefbDja0nhVKEDUsoHHpQCMwgwUb1ERwRtwBWxgEEMDtqbVIBNv5/zuuEunq Rf7anHPaVrbTELYyAyK7T8VXHUeDLBT5tw0RP0z0NSSK/SxO3YwLFr+q04YNR+dWAmwe 8640VyvaivSsoKM4Jik82kERMYdYrfg4MkYCTBIs2HC9p9sdJNrsjSocIN6UPRpUfois L4NA== 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=YJl5lyW9HwFQIPh1GGcTkaQcdhbOHO57znGtmzL1DGU=; b=MynLjLcgfGmnfVZOmzfVjbibHcmyFLCXLPXN90rcfv0oYXx8GdXCmV8Ql5AAceKJui D0NiIf84eK9ilbDx01v8mwgqbe5Qpy06yKsnW8VFvdc7DS6O4vjkDjYph89if9dy+Q3X 5wjxVXkOpqqw8e3EP/AW7FtKo+HUEWiREOtSinqJolsOYcjPataPNPTNKXLYf6sPG2Lf Sz+qIL/MonXIrqop4ALMgO9fIuiE3XK81fZFdxcCDHnCYcuQfL4Gj7mNCMjyYtet3q6G 6UgA2lrVFVohVemTZp1/o6x52lQa0pnEzAHsV9uigDK0traXyJBgElFFFcMG/N/Jg6u5 UCFQ== 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 c12-20020a170906528c00b00977ca8e3819si98831ejm.533.2023.06.08.10.18.49; Thu, 08 Jun 2023 10:18: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; 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 C9DFC68C316; Thu, 8 Jun 2023 20:18:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-01-1.mymagenta.at (mail-01-1.mymagenta.at [80.109.253.246]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 235CE68C2A5 for ; Thu, 8 Jun 2023 20:18:28 +0300 (EEST) Received: from [192.168.232.136] (helo=ren-mail-psmtp-mg02.) by mail-01.mymagenta.at with esmtp (Exim 4.93) (envelope-from ) id 1q7JHG-003tgh-R1 for ffmpeg-devel@ffmpeg.org; Thu, 08 Jun 2023 19:18:26 +0200 Received: from localhost ([84.115.40.24]) by ren-mail-psmtp-mg02. with ESMTP id 7JHIqT0k8bZLD7JHIqqQSb; Thu, 08 Jun 2023 19:18:28 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 84.115.40.24 X-CNFS-Analysis: v=2.4 cv=Ufwy9IeN c=1 sm=1 tr=0 ts=64820d64 a=4thelYDX6rwh+ygQwvsI+Q==:117 a=4thelYDX6rwh+ygQwvsI+Q==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=NEAV23lmAAAA:8 a=UIWwtVSi1I4jYkAQuIIA:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 8 Jun 2023 19:18:24 +0200 Message-Id: <20230608171825.6575-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230608171825.6575-1-michael@niedermayer.cc> References: <20230608171825.6575-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4xfKSk40PW45ycocV+r/K4/WpbkGsYArzeWASmQNiiY0CmuacYVcNpJ6Xhrbi0wUBoCGeuqVpkHBHzL43iitECSnoq+Xb483+HJ16hvufzQQmzTrC6n9jY ms+O26/Wwu/OXf1yXNHQDaWTlXdm8LleldjD4HQ0c1JBXv2t6MAuNaR7c1rv5jG93wF4kPpb62eYew== Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/mpegvideo_dec: consider interlaced lowres 4:2:0 chroma in edge emulation check better 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: T9BIwnnS/eZF Fixes: out of array read Fixes: 59673/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG1VIDEO_fuzzer-5194311374077952 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/mpegvideo_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index 765ccd0ba4..c87ca77ae6 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -640,6 +640,7 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, const int s_mask = (2 << lowres) - 1; const int h_edge_pos = s->h_edge_pos >> lowres; const int v_edge_pos = s->v_edge_pos >> lowres; + int hc = s->chroma_y_shift ? (h+1-bottom_field)>>1 : h; linesize = s->current_picture.f->linesize[0] << field_based; uvlinesize = s->current_picture.f->linesize[1] << field_based; @@ -702,7 +703,7 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x; if ((unsigned) src_x > FFMAX( h_edge_pos - (!!sx) - 2 * block_s, 0) || uvsrc_y<0 || - (unsigned) src_y > FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) { + (unsigned) src_y > FFMAX((v_edge_pos >> field_based) - (!!sy) - FFMAX(h, hc<chroma_y_shift), 0)) { s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr_y, linesize >> field_based, linesize >> field_based, 17, 17 + field_based, @@ -747,7 +748,6 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, pix_op[lowres - 1](dest_y, ptr_y, linesize, h, sx, sy); if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { - int hc = s->chroma_y_shift ? (h+1-bottom_field)>>1 : h; uvsx = (uvsx << 2) >> lowres; uvsy = (uvsy << 2) >> lowres; if (hc) { From patchwork Thu Jun 8 17:18:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42018 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp564503pzb; Thu, 8 Jun 2023 10:18:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6q8HoGoCP+Fdam/Ai4nlU9V3YxGJUPISfH339vA8bBx9xlDOZKfKRJ1WLpmhjDechGOzw7 X-Received: by 2002:a17:907:e92:b0:966:4d75:4a44 with SMTP id ho18-20020a1709070e9200b009664d754a44mr483520ejc.24.1686244738335; Thu, 08 Jun 2023 10:18:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686244738; cv=none; d=google.com; s=arc-20160816; b=YF1J9Li4+RT5EKscfB1EhUrhSCZEEAg+iYi2XNSr33VHyFNXKjM7Et5YuYZlEYcspM gNqvkAiZReUcGftBNUUpT74yc9anMr5gme5yq4dezrUbT42xYyGkXfMB2ztu7lm99g7m xBE2uPrNuaE0tWpRSg87sXkdUVKTjenfC7RClfJ23mAePjfoYH37bgyo0kEtzP2dxXk2 ugDoR/7w2fnbhu06lwfQT8/GYAjpZGn0tRaHXz4QMnplbgN0gpKQroOmhlece9EUFSgs 1hAU53ngvXGo4BsFVlYk6LSdTi0y3wmKdwhVZzMjgMJrs2KGanzqidDipBdVgSk2xhn0 ITjg== 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=HF+7UQGu7rxdWaiLGtuzJHKUOOuwEizdbGxjExcJKtY=; b=m66ITvGi3r2dMHGWIoyrS8Hw9dI2peclReqYRQBJGU0YX90vAzXtMtoaRBdoI+CR6z 1B9W+uDIR5z0ovJJ1HlwbgDnBhUtsE2RVpQ2rCzRAiAXQsdpjDqLh9yoPVR6uR6QtiRk ++GG8+8gJtz5bY1OEvOT0bw7OaCWmcxKi7s89kRMrPm4AMWDHhfb+TDAXKdePdziip7l p1UuW2ZpVu5rDNLPRPIg146dy4D4t2kZnssdm4MhEltNNdbadUn5iMTH4gj1bRTUlClq XsvFptpNpxTUQCw+ks5OtwZ96109WxdlUetr/qUkQQSnXnMyJm3iW6LMHwKF4dcd7bG5 uP/A== 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 y25-20020a170906915900b009745ee66afcsi107473ejw.411.2023.06.08.10.18.58; Thu, 08 Jun 2023 10:18:58 -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 E6E9D68C321; Thu, 8 Jun 2023 20:18:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-02-1.mymagenta.at (mail-02-1.mymagenta.at [80.109.253.248]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3116A68C2D0 for ; Thu, 8 Jun 2023 20:18:28 +0300 (EEST) Received: from [192.168.232.135] (helo=ren-mail-psmtp-mg01.) by mail-02.mymagenta.at with esmtp (Exim 4.93) (envelope-from ) id 1q7JHH-00FzEH-OP for ffmpeg-devel@ffmpeg.org; Thu, 08 Jun 2023 19:18:27 +0200 Received: from localhost ([84.115.40.24]) by ren-mail-psmtp-mg01. with ESMTP id 7JHGqe19fOG5Z7JHGqGBHy; Thu, 08 Jun 2023 19:18:26 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 84.115.40.24 X-CNFS-Analysis: v=2.4 cv=KJo5sHJo c=1 sm=1 tr=0 ts=64820d62 a=4thelYDX6rwh+ygQwvsI+Q==:117 a=4thelYDX6rwh+ygQwvsI+Q==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=NEAV23lmAAAA:8 a=XHJqly81KHHAeRfHM8AA:9 a=007GpJTbgYf-BIa_CBI3:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 8 Jun 2023 19:18:25 +0200 Message-Id: <20230608171825.6575-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230608171825.6575-1-michael@niedermayer.cc> References: <20230608171825.6575-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4xfGj9YK3SS/XvTeozfJ3diLP0BFT98CA+2ID/uyncOLb1EFuVNgv5kAGZi7LYC6yxjRkNutiwm1svBkkQ4iK+UYkQQoOmmt+oMp/A9pNAWV/MDsg/fi+b ZnImDJfIHd4TsU/R3tebopU99pKKtlhVSnt5OcgiIPmEBAHXdI6NfV9fEueFc9hVidluuvzQHARq9Q== Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/mpegvideo_dec: Add NULL pointer checks to MPV_motion_lowres() 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: mihlRd7kdct8 This makes the null pointer checks match mpv_motion_internal() Fixes: NULL pointer dereference Fixes: 59671/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG1VIDEO_fuzzer-4993004566609920 Fixes: 59678/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEGVIDEO_fuzzer-4893168991338496 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/mpegvideo_dec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index c87ca77ae6..fcca147cd6 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -885,10 +885,9 @@ static inline void MPV_motion_lowres(MpegEncContext *s, s->mv[dir][1][0], s->mv[dir][1][1], block_s, mb_y); } else { - if (s->picture_structure != s->field_select[dir][0] + 1 && - s->pict_type != AV_PICTURE_TYPE_B && !s->first_field) { + if ( s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != AV_PICTURE_TYPE_B && !s->first_field + || !ref_picture[0]) { ref_picture = s->current_picture_ptr->f->data; - } mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, 0, s->field_select[dir][0], @@ -901,8 +900,9 @@ static inline void MPV_motion_lowres(MpegEncContext *s, for (int i = 0; i < 2; i++) { uint8_t *const *ref2picture; - if (s->picture_structure == s->field_select[dir][i] + 1 || - s->pict_type == AV_PICTURE_TYPE_B || s->first_field) { + if ((s->picture_structure == s->field_select[dir][i] + 1 || + s->pict_type == AV_PICTURE_TYPE_B || s->first_field) && + ref_picture[0]) { ref2picture = ref_picture; } else { ref2picture = s->current_picture_ptr->f->data; @@ -933,6 +933,9 @@ static inline void MPV_motion_lowres(MpegEncContext *s, pix_op = s->h264chroma.avg_h264_chroma_pixels_tab; } } else { + if (!ref_picture[0]) { + ref_picture = s->current_picture_ptr->f->data; + } for (int i = 0; i < 2; i++) { mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, 0, s->picture_structure != i + 1,