• [gentoo-dev] [PATCH] go-module.eclass: ensure that A is less than 112 K

    From Florian Schmaus@21:1/5 to All on Tue Oct 11 12:10:01 2022
    Packages with a large number of EGO_SUM entries, i.e., many thousands,
    cause SRC_URI, and in turn A, to become quite large. Prevent issues that
    are caused by large environment variables, e.g., execve() errors (see
    bug #719203), by ensuring that A stays below a reasonable size.

    Signed-off-by: Florian Schmaus <flow@gentoo.org>
    ---
    eclass/go-module.eclass | 9 +++++++++
    1 file changed, 9 insertions(+)

    diff --git a/eclass/go-module.eclass b/eclass/go-module.eclass
    index 8047d498b08d..88414b7e9459 100644
    --- a/eclass/go-module.eclass
    +++ b/eclass/go-module.eclass
    @@ -377,6 +377,15 @@ _go-module_src_unpack_gosum() {
    die "go-module_set_globals must be called in global scope"
    fi

    + local -i a_size="${#A}"
    + # Environment variables must not exceed MAX_ARG_STRLEN (128 KiB) on
    + # Linux, or otherwise execve() may fail. Ensure that A stays below
    + # this value. See also https://bugs.gentoo.org/719202#c16
    + if [[ ${a_size} -gt 114688 ]]; then
    + # A is larger than 112 KiB.
    + die "Size of A variable (${a_size} bytes) is too large. Please use a dependency tarball instead of EGO_SUM."
    + fi
    +
    local goproxy_dir="${GOPROXY/file:\/\//}"
    mkdir -p "${goproxy_dir}" || die

    --
    2.35.1

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mike Gilbert@21:1/5 to flow@gentoo.org on Tue Oct 11 17:30:01 2022
    On Tue, Oct 11, 2022 at 6:06 AM Florian Schmaus <flow@gentoo.org> wrote:

    Packages with a large number of EGO_SUM entries, i.e., many thousands,
    cause SRC_URI, and in turn A, to become quite large. Prevent issues that
    are caused by large environment variables, e.g., execve() errors (see
    bug #719203), by ensuring that A stays below a reasonable size.

    This code will never be reached: if the A environment variable is too
    large, portage will fail to execute /bin/bash, and the phase function
    will not be executed.

    If you want to add an error for this, I think it would require changes
    to Portage's python code.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)