Skip to content

Commit

Permalink
squashfs: fix off by one in directory counting
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 committed Dec 14, 2023
1 parent 3e68808 commit 7a484b5
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 7a484b5

Please sign in to comment.