[protocol] Archive: the release's own root (./) is an allowed directory entry

This commit is contained in:
2026-11-17 13:12:53 +01:00
parent b4e63423c9
commit 5999847bce
+4 -2
View File
@@ -52,7 +52,7 @@ impl ArchiveError {
}
}
/// Check one entry and return its path as plain components (no `.`, never empty).
/// Check one entry and return its path as plain components (no `.`; empty only for the root dir).
pub fn check_entry(kind: EntryKind, path: &str, size: u64) -> Result<Vec<String>, ArchiveError> {
match kind {
EntryKind::File | EntryKind::Dir => {}
@@ -78,7 +78,9 @@ pub fn check_entry(kind: EntryKind, path: &str, size: u64) -> Result<Vec<String>
c => parts.push(c.to_owned()),
}
}
if parts.is_empty() {
// The release's own root (`./`, as `tar -C dir -czf x .` writes it) names nothing: allowed for a
// directory, refused for anything else.
if parts.is_empty() && kind != EntryKind::Dir {
return Err(ArchiveError::Path);
}
Ok(parts)