From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1482210-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 88986158010
	for <garchives@archives.gentoo.org>; Mon, 30 Jan 2023 14:44:21 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id AD5F1E09EA;
	Mon, 30 Jan 2023 14:44:20 +0000 (UTC)
Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 945E4E09EA
	for <gentoo-commits@lists.gentoo.org>; Mon, 30 Jan 2023 14:44:20 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id B1813335DE9
	for <gentoo-commits@lists.gentoo.org>; Mon, 30 Jan 2023 14:44:19 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id ABF4D771
	for <gentoo-commits@lists.gentoo.org>; Mon, 30 Jan 2023 14:44:17 +0000 (UTC)
From: "Andreas Sturmlechner" <asturm@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Andreas Sturmlechner" <asturm@gentoo.org>
Message-ID: <1675089845.631dcc854482ebd56ee3e642d96ea30ad1d87e82.asturm@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: kde-frameworks/kimageformats/, kde-frameworks/kimageformats/files/
X-VCS-Repository: repo/gentoo
X-VCS-Files: kde-frameworks/kimageformats/files/kimageformats-5.102.0-heif-reject-invalid-files-w-0-size.patch kde-frameworks/kimageformats/kimageformats-5.102.0-r1.ebuild
X-VCS-Directories: kde-frameworks/kimageformats/files/ kde-frameworks/kimageformats/
X-VCS-Committer: asturm
X-VCS-Committer-Name: Andreas Sturmlechner
X-VCS-Revision: 631dcc854482ebd56ee3e642d96ea30ad1d87e82
X-VCS-Branch: master
Date: Mon, 30 Jan 2023 14:44:17 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: faca7b5e-467d-4c5f-8cba-51851e567bc3
X-Archives-Hash: b3bfe47417e8a5e9366cff2d553efedc

commit:     631dcc854482ebd56ee3e642d96ea30ad1d87e82
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 30 10:36:30 2023 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Mon Jan 30 14:44:05 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=631dcc85

kde-frameworks/kimageformats: heif: reject invalid files with zero size

Upstream commit b654f20ecebc30ab73022a6b32c2fd1cef162ea6

See also: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=50850

Bug: https://bugs.gentoo.org/891927
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 ....102.0-heif-reject-invalid-files-w-0-size.patch | 31 +++++++++++++++
 .../kimageformats/kimageformats-5.102.0-r1.ebuild  | 46 ++++++++++++++++++++++
 2 files changed, 77 insertions(+)

diff --git a/kde-frameworks/kimageformats/files/kimageformats-5.102.0-heif-reject-invalid-files-w-0-size.patch b/kde-frameworks/kimageformats/files/kimageformats-5.102.0-heif-reject-invalid-files-w-0-size.patch
new file mode 100644
index 000000000000..809d11ce382f
--- /dev/null
+++ b/kde-frameworks/kimageformats/files/kimageformats-5.102.0-heif-reject-invalid-files-w-0-size.patch
@@ -0,0 +1,31 @@
+From b654f20ecebc30ab73022a6b32c2fd1cef162ea6 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Daniel=20Novomesk=C3=BD?= <dnovomesky@gmail.com>
+Date: Sun, 29 Jan 2023 16:16:52 +0100
+Subject: [PATCH] heif: reject invalid files with zero size
+
+---
+ src/imageformats/heif.cpp | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/src/imageformats/heif.cpp b/src/imageformats/heif.cpp
+index 3365d92..c938c0d 100644
+--- a/src/imageformats/heif.cpp
++++ b/src/imageformats/heif.cpp
+@@ -449,6 +449,14 @@ bool HEIFHandler::ensureDecoder()
+         return false;
+     }
+ 
++    if ((heif_image_handle_get_width(handle) == 0) || (heif_image_handle_get_height(handle) == 0)) {
++        m_parseState = ParseHeicError;
++        heif_image_handle_release(handle);
++        heif_context_free(ctx);
++        qWarning() << "HEIC image has zero dimension";
++        return false;
++    }
++
+     const bool hasAlphaChannel = heif_image_handle_has_alpha_channel(handle);
+     const int bit_depth = heif_image_handle_get_luma_bits_per_pixel(handle);
+     heif_chroma chroma;
+-- 
+GitLab
+

diff --git a/kde-frameworks/kimageformats/kimageformats-5.102.0-r1.ebuild b/kde-frameworks/kimageformats/kimageformats-5.102.0-r1.ebuild
new file mode 100644
index 000000000000..fef1628f46c6
--- /dev/null
+++ b/kde-frameworks/kimageformats/kimageformats-5.102.0-r1.ebuild
@@ -0,0 +1,46 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+ECM_QTHELP="false"
+PVCUT=$(ver_cut 1-2)
+QTMIN=5.15.5
+VIRTUALX_REQUIRED="test"
+inherit ecm frameworks.kde.org
+
+DESCRIPTION="Framework providing additional format plugins for Qt's image I/O system"
+
+LICENSE="LGPL-2+"
+KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc64 ~riscv ~x86"
+IUSE="avif eps heif jpegxl openexr raw"
+
+RDEPEND="
+	>=dev-qt/qtgui-${QTMIN}:5
+	=kde-frameworks/karchive-${PVCUT}*:5
+	avif? ( >=media-libs/libavif-0.8.2:= )
+	eps? ( >=dev-qt/qtprintsupport-${QTMIN}:5 )
+	heif? ( >=media-libs/libheif-1.10.0:= )
+	jpegxl? ( media-libs/libjxl )
+	openexr? ( >=media-libs/openexr-3:= )
+	raw? ( media-libs/libraw:= )
+"
+DEPEND="${RDEPEND}
+	test? ( heif? ( media-libs/libheif[x265] ) )
+"
+
+DOCS=( src/imageformats/AUTHORS )
+
+PATCHES=( "${FILESDIR}/${P}-heif-reject-invalid-files-w-0-size.patch" )
+
+src_configure() {
+	local mycmakeargs=(
+		-DKIMAGEFORMATS_JXL=$(usex jpegxl)
+		$(cmake_use_find_package avif libavif)
+		$(cmake_use_find_package eps Qt5PrintSupport)
+		-DKIMAGEFORMATS_HEIF=$(usex heif)
+		$(cmake_use_find_package openexr OpenEXR)
+		$(cmake_use_find_package raw LibRaw)
+	)
+	ecm_src_configure
+}