Skip to main content

validate_filename

Function validate_filename 

Source
pub fn validate_filename(filename: &[u8]) -> Result<()>
Expand description

Validate that filename is an acceptable external filename.

Checks, in order:

  1. Not empty.
  2. Not longer than MAX_FILENAME_LEN.
  3. No embedded NUL bytes.
  4. Not an absolute path (does not start with /).
  5. No .. path components.

Note that . components and empty components (from //) are permitted, as the kernel will handle them safely.

ยงErrors

Returns Error::InvalidFilename or Error::FilenameTooLong on failure.