From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 3AB7E1580FD for ; Mon, 23 Dec 2024 05:24:29 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7A973E084F; Mon, 23 Dec 2024 05:24:28 +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) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 39BE0E084F for ; Mon, 23 Dec 2024 05:24:28 +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 6DDD633BEB9 for ; Mon, 23 Dec 2024 05:24:27 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 8F0511048 for ; Mon, 23 Dec 2024 05:24:25 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1734931415.ab07577ee5982667cee52b561b0334c373ab8612.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/protobuf-c/, dev-libs/protobuf-c/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-libs/protobuf-c/files/protobuf-c-1.5.0-free-corruption.patch dev-libs/protobuf-c/protobuf-c-1.5.0-r4.ebuild X-VCS-Directories: dev-libs/protobuf-c/ dev-libs/protobuf-c/files/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: ab07577ee5982667cee52b561b0334c373ab8612 X-VCS-Branch: master Date: Mon, 23 Dec 2024 05:24:25 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 4520db79-e858-49b2-9e9a-00b867b8d9ec X-Archives-Hash: 1a0160ad3da38a216433756f02f15208 commit: ab07577ee5982667cee52b561b0334c373ab8612 Author: Sam James gentoo org> AuthorDate: Mon Dec 23 05:23:00 2024 +0000 Commit: Sam James gentoo org> CommitDate: Mon Dec 23 05:23:35 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ab07577e dev-libs/protobuf-c: backport memory corruption fix Note that this *doesn't* fix bug #946366, I just initially thought it did, so I mentioned it there. Bug: https://bugs.gentoo.org/946366 Signed-off-by: Sam James gentoo.org> .../files/protobuf-c-1.5.0-free-corruption.patch | 44 +++++++++++++++ dev-libs/protobuf-c/protobuf-c-1.5.0-r4.ebuild | 66 ++++++++++++++++++++++ 2 files changed, 110 insertions(+) diff --git a/dev-libs/protobuf-c/files/protobuf-c-1.5.0-free-corruption.patch b/dev-libs/protobuf-c/files/protobuf-c-1.5.0-free-corruption.patch new file mode 100644 index 000000000000..c6795231bbfc --- /dev/null +++ b/dev-libs/protobuf-c/files/protobuf-c-1.5.0-free-corruption.patch @@ -0,0 +1,44 @@ +https://github.com/protobuf-c/protobuf-c/issues/690 +https://github.com/protobuf-c/protobuf-c/pull/703 + +From 55c8b0dc688b070f4fa860d055a6365c0ae11bb3 Mon Sep 17 00:00:00 2001 +From: Stephan Mueller +Date: Sun, 21 Jan 2024 11:04:34 +0100 +Subject: [PATCH] Fix memory corruption by initlizalizing pointer + +A memory corruption in protobuf_c_message_free_unpacked happens at the +following line: + + if (message->unknown_fields != NULL) + do_free(allocator, message->unknown_fields); + +The do_free will free ->unknown_fields. This is may be wrong, because +protobuf_c_message_unpack uses malloc as the default allocator, allocates +rv with malloc. At the end, however, ->unknown_fields is only initialized +if there are some. That means if there are no such fields ->unknown_fields +is an uninitialized pointer. + +The patch initializes the pointer to NULL to ensure the check before free +is performed on initialized memory in case there is no unknown_field. + +This fixes https://github.com/protobuf-c/protobuf-c/issues/690 + +Signed-off-by: Stephan Mueller +--- + protobuf-c/protobuf-c.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/protobuf-c/protobuf-c.c b/protobuf-c/protobuf-c.c +index 776ee4fb..0c18f89b 100644 +--- a/protobuf-c/protobuf-c.c ++++ b/protobuf-c/protobuf-c.c +@@ -3278,6 +3278,8 @@ protobuf_c_message_unpack(const ProtobufCMessageDescriptor *desc, + n_unknown * sizeof(ProtobufCMessageUnknownField)); + if (rv->unknown_fields == NULL) + goto error_cleanup; ++ } else { ++ rv->unknown_fields = NULL; + } + + /* do real parsing */ + diff --git a/dev-libs/protobuf-c/protobuf-c-1.5.0-r4.ebuild b/dev-libs/protobuf-c/protobuf-c-1.5.0-r4.ebuild new file mode 100644 index 000000000000..d2ebd1a4e5f0 --- /dev/null +++ b/dev-libs/protobuf-c/protobuf-c-1.5.0-r4.ebuild @@ -0,0 +1,66 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +# Check 'next' branch for backports. + +inherit autotools flag-o-matic multilib-minimal + +MY_PV="${PV/_/-}" +MY_P="${PN}-${MY_PV}" + +DESCRIPTION="Protocol Buffers implementation in C" +HOMEPAGE="https://github.com/protobuf-c/protobuf-c" +SRC_URI="https://github.com/${PN}/${PN}/releases/download/v${MY_PV}/${MY_P}.tar.gz" +S="${WORKDIR}/${MY_P}" + +LICENSE="BSD-2" +# Subslot == SONAME version +SLOT="0/1.0.0" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~loong ~mips ~ppc64 ~riscv ~sparc ~x86" +IUSE="static-libs" + +BDEPEND=" + >=dev-libs/protobuf-3:0 + virtual/pkgconfig +" +DEPEND=" + >=dev-libs/protobuf-3:0=[${MULTILIB_USEDEP}]" +# NOTE +# protobuf links to abseil-cpp libraries via it's .pc files. +# To cause rebuild when the abseil-cpp version changes we add it to RDEPEND only. +RDEPEND="${DEPEND} + dev-cpp/abseil-cpp:=[${MULTILIB_USEDEP}] +" + +PATCHES=( + "${FILESDIR}/${PN}-1.5.0-Clean-CMake.patch" + "${FILESDIR}/${P}-free-corruption.patch" +) + +src_prepare() { + default + eautoreconf +} + +src_configure() { + # Workaround for bug #946366 + append-flags $(test-flags-CC -fzero-init-padding-bits=unions) + + multilib-minimal_src_configure +} + +multilib_src_configure() { + local myeconfargs=( + $(use_enable static-libs static) + --enable-year2038 + ) + + ECONF_SOURCE="${S}" econf "${myeconfargs[@]}" +} + +multilib_src_install_all() { + find "${ED}" -name '*.la' -type f -delete || die + einstalldocs +}