Skip to main content

validate_file_path_with_context

Function validate_file_path_with_context 

Source
pub fn validate_file_path_with_context(path: &str) -> Result<(PathBuf, PathBuf)>
Expand description

Validates a file path and stores the CWD for later use-time validation

§SECURITY FIX #5: TOCTOU Prevention

Returns both the validated path and the CWD at validation time. Before using the path, call verify_path_still_valid() to ensure the CWD hasn’t changed and the path is still safe.

§Arguments

  • path - User-provided file path

§Returns

  • Ok((PathBuf, PathBuf)) - The path and the CWD at validation time
  • Err(io::Error) if validation fails