From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (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 4F13015807A for ; Fri, 06 Jun 2025 22:02:25 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (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) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 32D23343122 for ; Fri, 06 Jun 2025 22:02:25 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 32C9B1103C1; Fri, 06 Jun 2025 22:02:22 +0000 (UTC) Received: from smtp.gentoo.org (smtp.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 bobolink.gentoo.org (Postfix) with ESMTPS id 2B1B91103C1 for ; Fri, 06 Jun 2025 22:02:22 +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 DAAE134306A for ; Fri, 06 Jun 2025 22:02:21 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 4776E1EC7 for ; Fri, 06 Jun 2025 22:02:20 +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: <1749247336.bd6dc1f13a58a72fa24b7df0be8d30290c06a4c1.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/misc-functions.sh X-VCS-Directories: bin/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: bd6dc1f13a58a72fa24b7df0be8d30290c06a4c1 X-VCS-Branch: master Date: Fri, 06 Jun 2025 22:02:20 +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: f953c443-94ce-4877-9fc5-5c42f9261cf2 X-Archives-Hash: 5cc6aadf1376786455c0bb5e758a910d commit: bd6dc1f13a58a72fa24b7df0be8d30290c06a4c1 Author: Kerin Millar plushkava net> AuthorDate: Fri Jun 6 19:50:44 2025 +0000 Commit: Sam James gentoo org> CommitDate: Fri Jun 6 22:02:16 2025 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=bd6dc1f1 misc-functions.sh: split words safely in {die,success}_hooks() Presently, the die_hooks() and success_hooks() functions split the 'EBUILD_DEATH_HOOKS' and 'EBUILD_SUCCESS_HOOKS' variables by way of an unquoted expansion, making them sensitive to the prevailing value of IFS, as well as potentially performing pathname expansion on the resulting words. Address the issue by using read to separate the words into an array, and by ensuring that all expansions are quoted. Signed-off-by: Kerin Millar plushkava.net> Signed-off-by: Sam James gentoo.org> bin/misc-functions.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh index 47e7ae72e4..601f6b15bc 100755 --- a/bin/misc-functions.sh +++ b/bin/misc-functions.sh @@ -644,20 +644,26 @@ __dyn_rpm() { } die_hooks() { + local -a hooks + local IFS cmd + [[ -f ${PORTAGE_BUILDDIR}/.die_hooks ]] && return - local x - for x in ${EBUILD_DEATH_HOOKS} ; do - ${x} >&2 + read -rd '' -a hooks <<<"${EBUILD_DEATH_HOOKS}" + for cmd in "${hooks[@]}"; do + "${cmd}" >&2 done > "${PORTAGE_BUILDDIR}/.die_hooks" } success_hooks() { - local x - for x in ${EBUILD_SUCCESS_HOOKS} ; do - ${x} + local -a hooks + local IFS cmd + + read -rd '' -a hooks <<<"${EBUILD_SUCCESS_HOOKS}" + for cmd in "${hooks[@]}"; do + "${cmd}" done }