commit:     432c18cc91037ba1a3a253fee00e66b820a1df33
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Thu Jul  3 17:11:30 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jul  4 02:17:05 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=432c18cc

emerge-webrsync: don't tolerate an empty definition of FETCHCOMMAND

Presently, the get_fetchcommand() function considers the value of the
'FETCHCOMMAND' portage variable and composes a derivative command to be
conveyed by the fetch_file() function to the eval builtin. However, it
will tolerate a value that is either empty or blank, in which case the
invocation of the eval builtin will successfully do nothing.

Address this issue by having the get_fetchcommand() function check
whether the value of 'FETCHCOMMAND' is composed entirely of zero-or-more
blank characters and returning false in that event. The fetch_file()
function will duly respond by dying.

 * FETCHCOMMAND has been set as an empty or blank string
emerge-webrsync: couldn't parse FETCHCOMMAND

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/emerge-webrsync | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index c011c0cf6e..e704d04bf0 100755
--- a/bin/emerge-webrsync
+++ b/bin/emerge-webrsync
@@ -197,8 +197,8 @@ fetch_file() {
        # shellcheck disable=2034
        local URI=$1 FILE=$2
 
-       if [[ ! ${fetchcommand} ]]; then
-               fetchcommand=$(get_fetchcommand)
+       if [[ ! ${fetchcommand} ]] && ! fetchcommand=$(get_fetchcommand); then
+               die "couldn't parse FETCHCOMMAND"
        fi
 
        einfo "Fetching file ${FILE} ..."
@@ -217,6 +217,11 @@ fetch_file() {
 get_fetchcommand() {
        local cmd_name cmd_args opts
 
+       if [[ ${FETCHCOMMAND} == *([[:blank:]]) ]]; then
+               eerror "FETCHCOMMAND has been set as an empty or blank string"
+               return 1
+       fi
+
        # shellcheck disable=2153
        read -rd '' cmd_name cmd_args <<<"${FETCHCOMMAND}"
 

Reply via email to