From patchwork Thu Apr 27 18:38:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 41387 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp739947pzb; Thu, 27 Apr 2023 11:39:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5TLV3HOaxqUEVdLqjoIXT4wvUhYYbvyLoXaStzt9YkzmvDHY6iGpHN6WZm/tmdJykXb6k+ X-Received: by 2002:a17:907:930a:b0:94f:6316:ce8d with SMTP id bu10-20020a170907930a00b0094f6316ce8dmr2380615ejc.34.1682620741422; Thu, 27 Apr 2023 11:39:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682620741; cv=none; d=google.com; s=arc-20160816; b=b71gX54Yyibtov5vW0/pl60qn1oYBd/KXsNA2t+zdv86awFg2f+LUPbxf76hs8ueZ9 EbsZtuSkJJtoPeTn2YzTl64rZ5A5Cistzy/6TrE5dIfhgtBrAHSq0iuO3ulA0wKSrpvq QPcyt1JG3tFpmd5aZPnXYfsT6mXpQq+J93joxCa3pgP2msetyV6Dd3zhLcJQy7dJ25qp jY47VBjWb/hZ+zdX9ypt1cJI3x0CrlCZOwif99//K+G1o86zUtYkUQSm8GmorIh2eXvF C0LmqZvUNweRUYwRsx+CC6PWzWF/0BllzjqeaZvzvLiSQp1RCeZ0evAak0WcZivnK9hK BYVA== 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=AkByk+ZKo44IVrUqoj4NPB8FKL94a98rH4ShiilpntM=; b=bCX7ZIKtNVsird2du9KupiHNo0Un7koPBIeb+3ESRX++ihcnZzlR7X/c+lcMYC0rfk dlNa0+kgAzgoBqm+ZoRWFlYuZSr+engSY70+ySEjqIb9dhUEQJrFcpW0ch7RdFOF5ugL izuQ3/gYj6MGySF8jcczUYP9mM73N7hBS/HnLTqJIfNsbxctUHqE4RVeaNuI7v7kNPY7 UUw5GiTyt9AG6Y2kVPJk5cS35+Ps9Qj/fUtxp0nHI3k+24wp/ULNeY32LiX4ZtDJRtZd f5nsNqFxfaNFDND986dGjusQVlYRPs6ZsWCiJP+npojWT32c3orfJe+I5clq5ZTHtkTr DKoQ== 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 xj11-20020a170906db0b00b009572f8d8043si12283177ejb.979.2023.04.27.11.39.01; Thu, 27 Apr 2023 11:39:01 -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 4570E68BF56; Thu, 27 Apr 2023 21:38:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D037668BA7B for ; Thu, 27 Apr 2023 21:38:43 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 1984740002 for ; Thu, 27 Apr 2023 18:38:42 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 27 Apr 2023 20:38:39 +0200 Message-Id: <20230427183840.1015-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230427183840.1015-1-michael@niedermayer.cc> References: <20230427183840.1015-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/hevcdec: do not memcpy into itself 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: gQl8uXT/5Tzc Iam not sure if this buffer setup is intended but if it occurs memcpy() cannot always be used Fixes: memcpy-param-overlap Fixes: 58062/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-4717458841010176 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/hevcdec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 0fa4fdd59d..1e590ec5d0 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -1542,6 +1542,7 @@ static void luma_mc_uni(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride, src += y_off * srcstride + (x_off * (1 << s->ps.sps->pixel_shift)); if (x_off < QPEL_EXTRA_BEFORE || y_off < QPEL_EXTRA_AFTER || + s->frame->data[0] == ref->data[0] || x_off >= pic_width - block_w - QPEL_EXTRA_AFTER || y_off >= pic_height - block_h - QPEL_EXTRA_AFTER) { const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift;