Gentoo Archives: gentoo-dev

From: Florian Schmaus <flow@g.o>
To: gentoo-dev@l.g.o
Cc: Florian Schmaus <flow@g.o>
Subject: [gentoo-dev] [PATCH] go-module.eclass: ensure that A is less than 112 KiB
Date: Tue, 11 Oct 2022 10:07:22
Message-Id: 20221011100646.1677690-2-flow@gentoo.org
In Reply to: [gentoo-dev] RFC: check A's size in go-module.eclass by Florian Schmaus
1 Packages with a large number of EGO_SUM entries, i.e., many thousands,
2 cause SRC_URI, and in turn A, to become quite large. Prevent issues that
3 are caused by large environment variables, e.g., execve() errors (see
4 bug #719203), by ensuring that A stays below a reasonable size.
5
6 Signed-off-by: Florian Schmaus <flow@g.o>
7 ---
8 eclass/go-module.eclass | 9 +++++++++
9 1 file changed, 9 insertions(+)
10
11 diff --git a/eclass/go-module.eclass b/eclass/go-module.eclass
12 index 8047d498b08d..88414b7e9459 100644
13 --- a/eclass/go-module.eclass
14 +++ b/eclass/go-module.eclass
15 @@ -377,6 +377,15 @@ _go-module_src_unpack_gosum() {
16 die "go-module_set_globals must be called in global scope"
17 fi
18
19 + local -i a_size="${#A}"
20 + # Environment variables must not exceed MAX_ARG_STRLEN (128 KiB) on
21 + # Linux, or otherwise execve() may fail. Ensure that A stays below
22 + # this value. See also https://bugs.gentoo.org/719202#c16
23 + if [[ ${a_size} -gt 114688 ]]; then
24 + # A is larger than 112 KiB.
25 + die "Size of A variable (${a_size} bytes) is too large. Please use a dependency tarball instead of EGO_SUM."
26 + fi
27 +
28 local goproxy_dir="${GOPROXY/file:\/\//}"
29 mkdir -p "${goproxy_dir}" || die
30
31 --
32 2.35.1

Replies