Skip to content

Commit 3ff17a2

Browse files
authored
Respect context in unzip function (#467)
1 parent 815ff8b commit 3ff17a2

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

internal/campaigns/bind_workspace.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ func unzipToTempDir(ctx context.Context, zipFile, tempDir, tempFilePrefix string
167167
return "", err
168168
}
169169

170-
return volumeDir, unzip(zipFile, volumeDir)
170+
return volumeDir, unzip(ctx, zipFile, volumeDir)
171171
}
172172

173-
func unzip(zipFile, dest string) error {
173+
func unzip(ctx context.Context, zipFile, dest string) error {
174174
r, err := zip.OpenReader(zipFile)
175175
if err != nil {
176176
return err
@@ -180,6 +180,12 @@ func unzip(zipFile, dest string) error {
180180
outputBase := filepath.Clean(dest) + string(os.PathSeparator)
181181

182182
for _, f := range r.File {
183+
select {
184+
case <-ctx.Done():
185+
return ctx.Err()
186+
default:
187+
}
188+
183189
fpath := filepath.Join(dest, f.Name)
184190

185191
// Check for ZipSlip. More Info: https://snyk.io/research/zip-slip-vulnerability#go

0 commit comments

Comments
 (0)