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

If a file path references a parent directory, transform it to ensure we keep inside the OUT_DIR #786

Merged
merged 1 commit into from
Feb 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1037,9 +1037,10 @@ impl Build {

let mut objects = Vec::new();
for file in self.files.iter() {
let obj = if file.has_root() {
// If `file` is an absolute path, prefix the `basename`
// with the `dirname`'s hash to ensure name uniqueness.
let obj = if file.has_root() || file.components().any(|x| x == Component::ParentDir) {
// If `file` is an absolute path or might not be usable directly as a suffix due to
// using "..", use the `basename` prefixed with the `dirname`'s hash to ensure name
// uniqueness.
let basename = file
.file_name()
.ok_or_else(|| Error::new(ErrorKind::InvalidArgument, "file_name() failure"))?
Expand Down