diff options
author | Ryan Hendrickson <ryan.hendrickson@alum.mit.edu> | 2023-09-18 02:49:33 -0400 |
---|---|---|
committer | Ryan Hendrickson <ryan.hendrickson@alum.mit.edu> | 2023-09-18 02:49:33 -0400 |
commit | df8b425f8990cf8c6cd8a4477a70995bdd4fe2a4 (patch) | |
tree | 810e76ee96730cd60b5a4d825fdfd3c54164d679 /pkgs/build-support/setup-hooks/make-binary-wrapper | |
parent | 9acebc35f912a32310c184265d0bbff1d25f8e50 (diff) | |
download | nixpkgs-df8b425f8990cf8c6cd8a4477a70995bdd4fe2a4.tar nixpkgs-df8b425f8990cf8c6cd8a4477a70995bdd4fe2a4.tar.gz nixpkgs-df8b425f8990cf8c6cd8a4477a70995bdd4fe2a4.tar.bz2 nixpkgs-df8b425f8990cf8c6cd8a4477a70995bdd4fe2a4.tar.lz nixpkgs-df8b425f8990cf8c6cd8a4477a70995bdd4fe2a4.tar.xz nixpkgs-df8b425f8990cf8c6cd8a4477a70995bdd4fe2a4.tar.zst nixpkgs-df8b425f8990cf8c6cd8a4477a70995bdd4fe2a4.zip |
makeBinaryWrapper: protect wildcards in flags
Diffstat (limited to 'pkgs/build-support/setup-hooks/make-binary-wrapper')
-rw-r--r-- | pkgs/build-support/setup-hooks/make-binary-wrapper/make-binary-wrapper.sh | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pkgs/build-support/setup-hooks/make-binary-wrapper/make-binary-wrapper.sh b/pkgs/build-support/setup-hooks/make-binary-wrapper/make-binary-wrapper.sh index 88a50befd73..6cd01f6bf63 100644 --- a/pkgs/build-support/setup-hooks/make-binary-wrapper/make-binary-wrapper.sh +++ b/pkgs/build-support/setup-hooks/make-binary-wrapper/make-binary-wrapper.sh @@ -193,8 +193,23 @@ makeCWrapper() { addFlags() { local n flag before after var + + # Disable file globbing, since bash will otherwise try to find + # filenames matching the the value to be prefixed/suffixed if + # it contains characters considered wildcards, such as `?` and + # `*`. We want the value as is, except we also want to split + # it on on the separator; hence we can't quote it. + local reenableGlob=0 + if [[ ! -o noglob ]]; then + reenableGlob=1 + fi + set -o noglob # shellcheck disable=SC2086 before=($1) after=($2) + if (( reenableGlob )); then + set +o noglob + fi + var="argv_tmp" printf '%s\n' "char **$var = calloc(${#before[@]} + argc + ${#after[@]} + 1, sizeof(*$var));" printf '%s\n' "assert($var != NULL);" |