File gradle-CVE-2021-32751.patch of Package gradle.28801
Index: gradle-4.4.1/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
===================================================================
--- gradle-4.4.1.orig/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+++ gradle-4.4.1/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
@@ -1,4 +1,4 @@
-#!/usr/bin/env sh
+#!/usr/bin/env bash
##############################################################################
##
@@ -161,12 +161,14 @@ save () {
}
APP_ARGS=\$(save "\$@")
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- \$DEFAULT_JVM_OPTS \$JAVA_OPTS \$${optsEnvironmentVar} <% if ( appNameSystemProperty ) { %>"\"-D${appNameSystemProperty}=\$APP_BASE_NAME\"" <% } %>-classpath "\"\$CLASSPATH\"" ${mainClassName} "\$APP_ARGS"
-
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "\$(uname)" = "Darwin" ] && [ "\$HOME" = "\$PWD" ]; then
cd "\$(dirname "\$0")"
fi
-exec "\$JAVACMD" "\$@"
+IFS=\$'\n' read -rd '' -a DEFAULT_JVM_OPTS_ARR <<< "\$(echo \$DEFAULT_JVM_OPTS | xargs -n1)"
+IFS=\$'\n' read -rd '' -a JAVA_OPTS_ARR <<< "\$(echo \$JAVA_OPTS | xargs -n1)"
+IFS=\$'\n' read -rd '' -a ${optsEnvironmentVar}_ARR <<< "\$(echo \$${optsEnvironmentVar} | xargs -n1)"
+
+exec "\$JAVACMD" "\${DEFAULT_JVM_OPTS_ARR[@]}" "\${JAVA_OPTS_ARR[@]}" "\${${optsEnvironmentVar}_ARR[@]}" <% if ( appNameSystemProperty ) { %>"\"-D${appNameSystemProperty}=\$APP_BASE_NAME\"" <% } %>-classpath "\$CLASSPATH" ${mainClassName} "\$@"
+