From fdc738b0df692b03a68a86e7f9a0dd8d8a5ae621 Mon Sep 17 00:00:00 2001 From: Mikhail Dmitrichenko Date: Thu, 20 Nov 2025 12:07:33 +0300 Subject: [PATCH] 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 --- pkg/machine/compression/uncompressed.go | 3 +++ pkg/machine/compression/zip.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/pkg/machine/compression/uncompressed.go b/pkg/machine/compression/uncompressed.go index 251a3a9ccc..4a0c8ff9cd 100644 --- a/pkg/machine/compression/uncompressed.go +++ b/pkg/machine/compression/uncompressed.go @@ -10,6 +10,9 @@ type uncompressedDecompressor struct { func newUncompressedDecompressor(compressedFilePath string) (*uncompressedDecompressor, error) { d, err := newGenericDecompressor(compressedFilePath) + if err != nil { + return nil, err + } return &uncompressedDecompressor{*d}, err } diff --git a/pkg/machine/compression/zip.go b/pkg/machine/compression/zip.go index 7de1f4813c..6aa9f2472b 100644 --- a/pkg/machine/compression/zip.go +++ b/pkg/machine/compression/zip.go @@ -16,6 +16,9 @@ type zipDecompressor struct { func newZipDecompressor(compressedFilePath string) (*zipDecompressor, error) { d, err := newGenericDecompressor(compressedFilePath) + if err != nil { + return nil, err + } return &zipDecompressor{*d, nil, nil}, err }