Fix second audit findings and restore crash detection dialog

This commit is contained in:
2026-02-27 22:48:43 +02:00
parent df8606251f
commit 1da69dd44e
21 changed files with 228 additions and 181 deletions

View File

@@ -396,8 +396,14 @@ pub fn dir_size_pub(path: &Path) -> u64 {
}
fn dir_size(path: &Path) -> u64 {
if path.is_file() {
return path.metadata().map(|m| m.len()).unwrap_or(0);
// Use symlink_metadata to avoid following symlinks outside the tree
if let Ok(meta) = path.symlink_metadata() {
if meta.is_file() {
return meta.len();
}
if meta.is_symlink() {
return 0;
}
}
let mut total = 0u64;
if let Ok(entries) = std::fs::read_dir(path) {
@@ -406,6 +412,10 @@ fn dir_size(path: &Path) -> u64 {
Ok(ft) => ft,
Err(_) => continue,
};
// Skip symlinks to avoid counting external files or recursing out of tree
if ft.is_symlink() {
continue;
}
if ft.is_file() {
total += entry.metadata().map(|m| m.len()).unwrap_or(0);
} else if ft.is_dir() {