Skip to content

Commit d19cfb6

Browse files
committed
fix: context extraction error
Context extraction error may occur when an archive contains file node without parent directory node. Fixes #4260. Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
1 parent 69e1bb0 commit d19cfb6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pkg/util/archive.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ func ExtractTar(tarFileReader io.Reader, dstDir string) error {
192192
return fmt.Errorf("unable to create new dir %q while extracting tar: %s", tarEntryPath, err)
193193
}
194194
case tar.TypeReg, tar.TypeSymlink, tar.TypeLink, tar.TypeGNULongName, tar.TypeGNULongLink:
195+
if err := os.MkdirAll(filepath.Dir(tarEntryPath), os.ModePerm); err != nil {
196+
return fmt.Errorf("unable to create new directory %q while extracting tar: %w", filepath.Dir(tarEntryPath), err)
197+
}
198+
195199
file, err := os.OpenFile(tarEntryPath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, tarEntryFileInfo.Mode())
196200
if err != nil {
197201
return fmt.Errorf("unable to create new file %q while extracting tar: %s", tarEntryPath, err)

0 commit comments

Comments
 (0)