Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cc_wrapper: Spill arguments back to a response file #430

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ParkMyCar
Copy link

Fixes #421

This PR tweaks the *cc_wraper.sh scripts to spill command line arguments from response files, back into a file after sanitizing. Previously they were expanded into the cmd variable which would then get specified on the command line, possibly leading to an overflow.

Copy link
Member

@fmeum fmeum left a comment

Choose a reason for hiding this comment

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

Thanks for picking this up!

if [[ ${!i} == @* && -r "${i:1}" ]]; then
# Create a temporary file that we'll spill sanitized options to since they
# were originally read from a response file.
temp_file=$(mktemp)
Copy link
Member

Choose a reason for hiding this comment

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

Can we do this only if the arguments have a length that gets somewhat close to the limit? Otherwise we are just doing needless file I/O.

done <"${!i:1}"
mv "${temp_file}" "${!i:1}"
Copy link
Member

Choose a reason for hiding this comment

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

This replaces an input file, which is something actions should avoid. Could we rewrite the argument to point to the temporary file instead?

done <"${!i:1}"
mv "${temp_file}" "${!i:1}"
else
Copy link
Member

Choose a reason for hiding this comment

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

The temporary file should be deleted after the compiler returns.

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.

Why are response files expanded in osx_cc_wrapper?
2 participants