Skip to main content

validate_write_target

Function validate_write_target 

Source
pub fn validate_write_target(
    target: &Path,
    expected_parent: &Path,
) -> Result<()>
Expand description

Validates that target resolves within expected_parent and is not itself a symlink.

The validation canonicalizes the parent directory of target and compares it to the canonicalized expected_parent to ensure no symlink in the parent chain escapes the intended directory. If target itself exists and is a symbolic link, an error is returned.

ยงErrors

Returns io::ErrorKind::PermissionDenied if the canonicalized parent escapes expected_parent, or if target is a symbolic link. Returns other I/O errors from canonicalization failures.