File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -325,6 +325,14 @@ struct TomlTarget {
325325}
326326
327327impl Config {
328+ fn path_from_python ( var_key : & str ) -> PathBuf {
329+ match env:: var_os ( var_key) {
330+ // Do not trust paths from Python and normalize them slightly (#49785).
331+ Some ( var_val) => Path :: new ( & var_val) . components ( ) . collect ( ) ,
332+ _ => panic ! ( "expected '{}' to be set" , var_key) ,
333+ }
334+ }
335+
328336 pub fn default_opts ( ) -> Config {
329337 let mut config = Config :: default ( ) ;
330338 config. llvm_enabled = true ;
@@ -348,9 +356,9 @@ impl Config {
348356 config. deny_warnings = true ;
349357
350358 // set by bootstrap.py
351- config. src = env:: var_os ( "SRC" ) . map ( PathBuf :: from) . expect ( "'SRC' to be set" ) ;
352359 config. build = INTERNER . intern_str ( & env:: var ( "BUILD" ) . expect ( "'BUILD' to be set" ) ) ;
353- config. out = env:: var_os ( "BUILD_DIR" ) . map ( PathBuf :: from) . expect ( "'BUILD_DIR' set" ) ;
360+ config. src = Config :: path_from_python ( "SRC" ) ;
361+ config. out = Config :: path_from_python ( "BUILD_DIR" ) ;
354362
355363 let stage0_root = config. out . join ( & config. build ) . join ( "stage0/bin" ) ;
356364 config. initial_rustc = stage0_root. join ( exe ( "rustc" , & config. build ) ) ;
You can’t perform that action at this time.
0 commit comments