Skip to content

Commit

Permalink
fixes config decompression lint issue
Browse files Browse the repository at this point in the history
This was caught by the gosec linter in the Hypershift project; gosec
G110.
  • Loading branch information
cheesesashimi committed Aug 22, 2022
1 parent bfb5d9f commit 49b591c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pkg/controller/common/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,21 +585,19 @@ func decompressPayload(r io.Reader) ([]byte, error) {
return nil, errConfigNotGzipped
}

out := bytes.NewBuffer([]byte{})

gz, err := gzip.NewReader(in)
if err != nil {
return nil, fmt.Errorf("initialize gzip reader failed: %w", err)
}

defer gz.Close()

// Decompress our payload.
if _, err := io.Copy(out, gz); err != nil {
data, err := ioutil.ReadAll(gz)
if err != nil {
return nil, fmt.Errorf("decompression failed: %w", err)
}

return out.Bytes(), nil
return data, nil
}

// Function to remove duplicated files/units/users from a V2 MC, since the translator
Expand Down

0 comments on commit 49b591c

Please sign in to comment.