Skip to content

Add quotes to prevent potential word splittings#590

Open
zzmic wants to merge 1 commit intoRenderKit:masterfrom
zzmic:word-split-fix
Open

Add quotes to prevent potential word splittings#590
zzmic wants to merge 1 commit intoRenderKit:masterfrom
zzmic:word-split-fix

Conversation

@zzmic
Copy link
Copy Markdown

@zzmic zzmic commented Mar 9, 2026

As the title suggests, this PR includes the commit that adds quotes to several commands in scripts/download_gfx.sh to prevent potential word splittings (related to https://www.shellcheck.net/wiki/SC2086). In particular, the previous line of rm -rf /tmp/${GFX_DRIVER} is concerning, since ${GFX_DRIVER} is unquoted, (1) if it contains whitespaces, it would be split into multiple arguments to rm -rf, and (2) if it is empty or resolves unexpectedly, the command becomes rm -rf /tmp/, which is even more catastrophic. Other quotes are added more for the sake of consistency, even though they do address the valid concern of word splitting (but they are not as concerning as rm -rf /tmp/${GFX_DRIVER}).

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates scripts/download_gfx.sh to quote shell variables in command invocations to prevent unintended word-splitting (ShellCheck SC2086), improving robustness when inputs contain spaces or other special characters.

Changes:

  • Quote positional parameter checks and path arguments used with mkdir, cd, cp, and rm.
  • Quote URL and package expansions in curl and dpkg calls.
  • Quote regex variable usage in grep -E for consistency (but see review comments for a correctness concern).
Comments suppressed due to low confidence (1)

scripts/download_gfx.sh:8

  • The usage guard only checks whether $3 is empty, but the script can still be invoked with an empty gfx-driver (e.g., passing "" as $1). That leads to creating/removing "/tmp/" and using an empty driver path elsewhere. Consider validating argument count (e.g., $# == 3) and rejecting empty $1/$2 explicitly.
if [ -z "$3" ]; then
  echo "ERROR: usage $0 gfx-driver target-directory token"
  echo "    gfx-driver: URL to the driver packages relative to artifactory URL (e.g. gfx-driver-builds/ci/master/gfx-driver-ci-master-9999/artifacts/Linux/Ubuntu/22.04/Release"
  echo "    token: access token to (artifactory) repository"
  exit 1

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/download_gfx.sh
Comment on lines 34 to 47
@@ -40,57 +40,57 @@ if [[ $GFX_DRIVER == *"linux"* ]] || [[ $GFX_DRIVER == *"Linux"* ]] ; then
else
DEBS="level-zero|intel-level-zero-gpu|intel-opencl-icd|libigc1|libigc-tools|libigdfcl1|libigdgmm"
fi
PACKAGES=$(curl -H "X-JFrog-Art-Api:$TOKEN" -s $URL |

PACKAGES=$(curl -H "X-JFrog-Art-Api:$TOKEN" -s "$URL" |
sed 's/<a href/\n<a href/g' | sed 's/.deb"/.deb"\n/g' |
grep -o '".*"' | grep deb | tr -d '"' | grep -E $DEBS |
grep -o '".*"' | grep deb | tr -d '"' | grep -E "$DEBS" |
grep -v devel | grep -v dev | grep -v debuginfo)
Comment thread scripts/download_gfx.sh
Comment on lines +44 to 47
PACKAGES=$(curl -H "X-JFrog-Art-Api:$TOKEN" -s "$URL" |
sed 's/<a href/\n<a href/g' | sed 's/.deb"/.deb"\n/g' |
grep -o '".*"' | grep deb | tr -d '"' | grep -E $DEBS |
grep -o '".*"' | grep deb | tr -d '"' | grep -E "$DEBS" |
grep -v devel | grep -v dev | grep -v debuginfo)
Comment thread scripts/download_gfx.sh
Comment on lines +93 to +94
cd "${CUR_DIR}"
rm -rf "/tmp/${GFX_DRIVER}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants