Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions extractor/filesystem/embeddedfs/qcow2/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ func parseHeader(reader io.Reader) (*header, []headerExtension, error) {
}

func readL1Table(header *header, reader io.ReaderAt) ([]uint64, error) {
if header.ClusterBits < 9 || header.ClusterBits > 21 {
return nil, fmt.Errorf("invalid ClusterBits value: %d", header.ClusterBits)
}
l1Table := make([]uint64, header.L1Size)
buf := make([]byte, header.L1Size*8)
if _, err := reader.ReadAt(buf, int64(header.L1TableOffset)); err != nil {
Expand All @@ -203,6 +206,9 @@ func readL1Table(header *header, reader io.ReaderAt) ([]uint64, error) {
}

func readL2Table(l1Entry uint64, header *header, reader io.ReaderAt) ([]uint64, error) {
if header.ClusterBits < 9 || header.ClusterBits > 21 {
return nil, fmt.Errorf("invalid ClusterBits value: %d", header.ClusterBits)
}
if l1Entry == 0 {
return nil, nil
}
Expand Down
3 changes: 3 additions & 0 deletions extractor/filesystem/embeddedfs/vdi/vdi.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ func convertVDIToRaw(in io.Reader, out io.Writer) error {
curPos = int64(hdr.OffsetBmap)
}

if hdr.BlocksInImage > 2*1024*1024 {
return fmt.Errorf("BlocksInImage %d exceeds maximum allowed value", hdr.BlocksInImage)
}
indices := make([]uint32, hdr.BlocksInImage)
if err := binary.Read(in, binary.LittleEndian, &indices); err != nil {
return fmt.Errorf("failed to read block map: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions extractor/filesystem/embeddedfs/vmdk/vmdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,12 @@ func getGDGT(hdr sparseExtentHeader) (*gdgtInfo, error) {
GTs := uint32((GTEs + uint64(hdr.NumGTEsPerGT) - 1) / uint64(hdr.NumGTEsPerGT))
GDsectors := uint32((uint64(GTs)*4 + SectorSize - 1) / SectorSize)
GTsectors := uint32((uint64(hdr.NumGTEsPerGT)*4 + SectorSize - 1) / SectorSize)
totalSectors := int64(GDsectors + GTsectors*GTs)
totalSectors := int64(GDsectors) + int64(GTsectors)*int64(GTs)
totalBytes := totalSectors * SectorSize
if totalBytes > 1<<31 {
return nil, fmt.Errorf("gd/gt allocation too large: %d bytes", totalBytes)
}
gdarr := make([]uint32, (GDsectors*SectorSize)/4+(GTsectors*GTs*SectorSize)/4)
gdarr := make([]uint32, (int64(GDsectors)*SectorSize/4)+(int64(GTsectors)*int64(GTs)*SectorSize/4))
info := &gdgtInfo{
GTEs: GTEs,
GTs: GTs,
Expand Down
Loading