Skip to content

fix(coderd): correctly handle tar dir entries with missing path separator #12479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(provisionersdk): add trailing path separator to directory entries
  • Loading branch information
johnstcn committed Mar 11, 2024
commit 7815d3ea34043d3722a61643715c7ffe6111de93
5 changes: 5 additions & 0 deletions provisionersdk/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ func Tar(w io.Writer, logger slog.Logger, directory string, limit int64) error {
}
// Use unix paths in the tar archive.
header.Name = filepath.ToSlash(rel)
// tar.FileInfoHeader() will do this, but filepath.Rel() calls filepath.Clean()
// which strips trailing path separators for directories.
if fileInfo.IsDir() {
header.Name += "/"
}
if err := tarWriter.WriteHeader(header); err != nil {
return err
}
Expand Down