Skip to content

Commit

Permalink
rustbuild: Normalize paths coming from Python slightly
Browse files Browse the repository at this point in the history
Fixes #49785
  • Loading branch information
petrochenkov committed May 1, 2018
1 parent 0d8321b commit 993f7c5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/bootstrap/config.rs
Expand Up @@ -325,6 +325,14 @@ struct TomlTarget {
}

impl Config {
fn path_from_python(var_key: &str) -> PathBuf {
match env::var_os(var_key) {
// Do not trust paths from Python and normalize them slightly (#49785).
Some(var_val) => Path::new(&var_val).components().collect(),
_ => panic!("expected '{}' to be set", var_key),
}
}

pub fn default_opts() -> Config {
let mut config = Config::default();
config.llvm_enabled = true;
Expand All @@ -348,9 +356,9 @@ impl Config {
config.deny_warnings = true;

// set by bootstrap.py
config.src = env::var_os("SRC").map(PathBuf::from).expect("'SRC' to be set");
config.build = INTERNER.intern_str(&env::var("BUILD").expect("'BUILD' to be set"));
config.out = env::var_os("BUILD_DIR").map(PathBuf::from).expect("'BUILD_DIR' set");
config.src = Config::path_from_python("SRC");
config.out = Config::path_from_python("BUILD_DIR");

let stage0_root = config.out.join(&config.build).join("stage0/bin");
config.initial_rustc = stage0_root.join(exe("rustc", &config.build));
Expand Down

0 comments on commit 993f7c5

Please sign in to comment.