Skip to content

Commit

Permalink
squashfs: fix off by one in directory counting (#193)
Browse files Browse the repository at this point in the history
This was causing "corrupted directory, had 257 entries instead of max
256" errors, however this was because parseDirectoryHeader had already
added one to the count.
  • Loading branch information
ncw authored Dec 14, 2023
1 parent 5a0c7db commit fa6a9c9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions filesystem/squashfs/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func parseDirectory(b []byte) (*directory, error) {
if err != nil {
return nil, fmt.Errorf("could not parse directory header: %v", err)
}
if directoryHeader.count+1 > maxDirEntries {
return nil, fmt.Errorf("corrupted directory, had %d entries instead of max %d", directoryHeader.count+1, maxDirEntries)
if directoryHeader.count > maxDirEntries {
return nil, fmt.Errorf("corrupted directory, had %d entries instead of max %d", directoryHeader.count, maxDirEntries)
}
pos += dirHeaderSize
for count := uint32(0); count < directoryHeader.count; count++ {
Expand Down

0 comments on commit fa6a9c9

Please sign in to comment.