From e3d0bd46164546a91fd180fcfd0bf42532b9b1eb Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 15 Dec 2023 16:30:28 +0000 Subject: [PATCH] squashfs: add check for unexpected block size --- filesystem/squashfs/file.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/filesystem/squashfs/file.go b/filesystem/squashfs/file.go index 327dbd43..e7c5790c 100644 --- a/filesystem/squashfs/file.go +++ b/filesystem/squashfs/file.go @@ -96,6 +96,9 @@ func (fl *File) Read(b []byte) (int, error) { } // if we are in the range of desired ones, read it in if i >= startBlock { + if int64(block.size) > fs.blocksize { + return read, fmt.Errorf("unexpected block.size=%d > fs.blocksize=%d", block.size, fs.blocksize) + } input, err := fs.readBlock(location, block.compressed, block.size) if err != nil { return read, fmt.Errorf("error reading data block %d from squashfs: %v", i, err)