This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 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> {
561561
562562/// Returns the path of a temporary directory.
563563///
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+ ///
564571/// # Unix
565572///
566573/// Returns the value of the `TMPDIR` environment variable if it is
@@ -580,14 +587,10 @@ pub fn home_dir() -> Option<PathBuf> {
580587///
581588/// ```no_run
582589/// use std::env;
583- /// use std::fs::File;
584590///
585- /// fn main() -> std::io::Result<()> {
591+ /// fn main() {
586592/// 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());
591594/// }
592595/// ```
593596#[ stable( feature = "env" , since = "1.0.0" ) ]
You can’t perform that action at this time.
0 commit comments