Skip to content

Commit 9e405c5

Browse files
committed
melib/maildir: validate fs path in list_mail_in_maildir_fs()
Validate that the path argument in list_mail_in_maildir_fs() is a valid maildir path. Signed-off-by: Manos Pitsidianakis <[email protected]>
1 parent 0cf7283 commit 9e405c5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

melib/src/maildir/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,17 @@ impl MaildirType {
920920
mut path: PathBuf,
921921
read_only: bool,
922922
) -> Result<Vec<PathBuf>> {
923+
for d in &["cur", "new", "tmp"] {
924+
path.push(d);
925+
if !path.is_dir() {
926+
path.pop();
927+
return Err(Error::new(format!(
928+
"{} is not a valid maildir mailbox",
929+
path.display()
930+
)));
931+
}
932+
path.pop();
933+
}
923934
let mut files: Vec<PathBuf> = vec![];
924935
path.push("new");
925936
for p in path.read_dir().chain_err_related_path(&path)?.flatten() {

0 commit comments

Comments
 (0)