File tree 1 file changed +9
-6
lines changed
1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -561,6 +561,13 @@ pub fn home_dir() -> Option<PathBuf> {
561
561
562
562
/// Returns the path of a temporary directory.
563
563
///
564
+ /// The temporary directory may be shared among users, or between processes
565
+ /// with different privileges; thus, the creation of any files or directories
566
+ /// in the temporary directory must use a secure method to create a uniquely
567
+ /// named file. Creating a file or directory with a fixed or predictable name
568
+ /// may result in "insecure temporary file" security vulnerabilities. Consider
569
+ /// using a crate that securely creates temporary files or directories.
570
+ ///
564
571
/// # Unix
565
572
///
566
573
/// Returns the value of the `TMPDIR` environment variable if it is
@@ -580,14 +587,10 @@ pub fn home_dir() -> Option<PathBuf> {
580
587
///
581
588
/// ```no_run
582
589
/// use std::env;
583
- /// use std::fs::File;
584
590
///
585
- /// fn main() -> std::io::Result<()> {
591
+ /// fn main() {
586
592
/// let mut dir = env::temp_dir();
587
- /// dir.push("foo.txt");
588
- ///
589
- /// let f = File::create(dir)?;
590
- /// Ok(())
593
+ /// println!("Temporary directory: {}", dir.display());
591
594
/// }
592
595
/// ```
593
596
#[ stable( feature = "env" , since = "1.0.0" ) ]
You can’t perform that action at this time.
0 commit comments