Skip to content

Commit

Permalink
fix: don't expose the . & .. entries to the end user
Browse files Browse the repository at this point in the history
  • Loading branch information
Oakchris1955 committed Sep 14, 2024
1 parent 842fce1 commit 02eb213
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/fat/fs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;

use crate::{error::*, io::prelude::*, path::PathBuf, time::*, utils};
use crate::{error::*, io::prelude::*, path::PathBuf, time::*, utils, SPECIAL_ENTRIES};

use core::{cmp, ops};

Expand Down Expand Up @@ -1315,6 +1315,8 @@ where
Ok(entries
.into_iter()
.filter(|x| self.filter.filter(x))
// we shouldn't expose the special entries to the user
.filter(|x| !SPECIAL_ENTRIES.contains(&x.name.as_str()))
.map(|rawentry| {
let mut entry_path = path.clone();

Expand Down
3 changes: 3 additions & 0 deletions src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ pub const RESERVED_FILENAMES: &[&str] = &[
"COM8", "COM9", "COM¹", "COM²", "COM³", "LPT0", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6",
"LPT7", "LPT8", "LPT9", "LPT¹", "LPT²", "LPT³",
];
/// Except for the root directory, each directory must contain
/// the following (two) entries at the beginning of the directory
pub(crate) const SPECIAL_ENTRIES: &[&str] = &[".", ".."];

/// Check whether a [`PathBuf`] is forbidden for use in filenames or directory names
fn is_forbidden(pathbuf: &PathBuf) -> bool {
Expand Down

0 comments on commit 02eb213

Please sign in to comment.