Disallow creating files with '..' (#3156)

Release Notes:

- Fixed a crash that could occur when creating files with '..' in the
path
This commit is contained in:
Conrad Irwin 2024-01-08 15:43:57 -07:00 committed by GitHub
commit 59a1648445
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 122 additions and 25 deletions

View file

@ -559,7 +559,7 @@ impl SemanticIndex {
.spawn(async move {
let mut changed_paths = BTreeMap::new();
for file in worktree.files(false, 0) {
let absolute_path = worktree.absolutize(&file.path);
let absolute_path = worktree.absolutize(&file.path)?;
if file.is_external || file.is_ignored || file.is_symlink {
continue;
@ -1068,11 +1068,10 @@ impl SemanticIndex {
return true;
};
worktree_state.changed_paths.retain(|path, info| {
for (path, info) in &worktree_state.changed_paths {
if info.is_deleted {
files_to_delete.push((worktree_state.db_id, path.clone()));
} else {
let absolute_path = worktree.read(cx).absolutize(path);
} else if let Ok(absolute_path) = worktree.read(cx).absolutize(path) {
let job_handle = JobHandle::new(pending_file_count_tx);
pending_files.push(PendingFile {
absolute_path,
@ -1083,9 +1082,8 @@ impl SemanticIndex {
worktree_db_id: worktree_state.db_id,
});
}
false
});
}
worktree_state.changed_paths.clear();
true
});