Skip to content

Commit fdc738b

Browse files
author
Mikhail Dmitrichenko
committed
fix: check err returned by newGenericDecompressor
There is a couple of newGenericDecompressor function usages, where returned possibly non-nil `err` is not checked before dereferencing returned decompressor. It may lead to nil ptr dereferencing. This commit adds check for `err` to prevent dereferencing potentially nullable decompressor. Found by Linux Verification Center (linuxtesting.org) with SVACE Signed-off-by: Mikhail Dmitrichenko <[email protected]>
1 parent 6541fc4 commit fdc738b

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

pkg/machine/compression/uncompressed.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ type uncompressedDecompressor struct {
1010

1111
func newUncompressedDecompressor(compressedFilePath string) (*uncompressedDecompressor, error) {
1212
d, err := newGenericDecompressor(compressedFilePath)
13+
if err != nil {
14+
return nil, err
15+
}
1316
return &uncompressedDecompressor{*d}, err
1417
}
1518

pkg/machine/compression/zip.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ type zipDecompressor struct {
1616

1717
func newZipDecompressor(compressedFilePath string) (*zipDecompressor, error) {
1818
d, err := newGenericDecompressor(compressedFilePath)
19+
if err != nil {
20+
return nil, err
21+
}
1922
return &zipDecompressor{*d, nil, nil}, err
2023
}
2124

0 commit comments

Comments
 (0)