public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/protobuf-c/, dev-libs/protobuf-c/files/
Date: Mon, 23 Dec 2024 05:24:25 +0000 (UTC)	[thread overview]
Message-ID: <1734931415.ab07577ee5982667cee52b561b0334c373ab8612.sam@gentoo> (raw)

commit:     ab07577ee5982667cee52b561b0334c373ab8612
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 23 05:23:00 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> 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 <sam <AT> 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 <smueller@chronox.de>
+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 <smueller@chronox.de>
+---
+ 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
+}


             reply	other threads:[~2024-12-23  5:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-23  5:24 Sam James [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-07-19  5:35 [gentoo-commits] repo/gentoo:master commit in: dev-libs/protobuf-c/, dev-libs/protobuf-c/files/ Sam James
2024-07-09 12:52 Sam James
2023-08-21 19:57 Sam James
2021-11-04 21:04 Sam James
2019-05-05 19:05 Mike Gilbert
2018-07-07  2:03 Mike Gilbert
2018-04-26 15:14 Mike Gilbert
2017-08-10  7:26 Lars Wendler
2016-04-07 11:29 Lars Wendler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1734931415.ab07577ee5982667cee52b561b0334c373ab8612.sam@gentoo \
    --to=sam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox