go-module.eclass: avoid heredoc in global scope with EGO_SUM

A heredoc may cause the use of a temporary file with < EAPI 9 and even
then still with >= EAPI 9 if the input is large. This becomes a problem
if sandboxing is applied to metadata generation.

Closes: https://bugs.gentoo.org/979141
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Sam James
2026-07-12 18:08:56 +01:00
parent a2a4a1e1ce
commit 088ecc18f0

View File

@@ -216,13 +216,13 @@ go-module_set_globals() {
# Now parse EGO_SUM
for line in "${EGO_SUM[@]}"; do
local module version modfile version_modfile kvs x
read -r module version_modfile kvs <<< "${line}"
read -rd '' module version_modfile kvs < <(printf %s "${line}")
# kvs contains the hash and may contain other data from
# upstream in the future. We do not currently use any of this data.
# Split 'v0.3.0/go.mod' into 'v0.3.0' and '/go.mod'
# It might NOT have the trailing /go.mod
IFS=/ read -r version modfile x <<<"${version_modfile}"
IFS=/ read -rd '' version modfile x < <(printf %s "${version_modfile}")
# Reject multiple slashes
if [[ -n ${x} ]]; then
error_in_gosum=1