Skip to content

Commit

Permalink
fix: stop index out of range on block boundaries
Browse files Browse the repository at this point in the history
Pulls in changes from 03266d0 in
upstream, without intermediate changes, and without stray println.
  • Loading branch information
willmurphyscode committed Dec 4, 2024
1 parent 3afc631 commit b93b36f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions low/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (r *Reader) Id(i uint16) (uint32, error) {
// Populate the id table as needed
var blockNum uint32
if i != 0 { // If i == 0, we go negatives causing issues with uint32s
blockNum = uint32(math.Ceil(float64(i)/2048)) - 1
blockNum = uint32(math.Ceil(float64(i+1)/2048)) - 1
} else {
blockNum = 0
}
Expand Down Expand Up @@ -129,7 +129,7 @@ func (r *Reader) fragEntry(i uint32) (fragEntry, error) {
// Populate the fragment table as needed
var blockNum uint32
if i != 0 { // If i == 0, we go negatives causing issues with uint32s
blockNum = uint32(math.Ceil(float64(i)/512)) - 1
blockNum = uint32(math.Ceil(float64(i+1)/512)) - 1
} else {
blockNum = 0
}
Expand Down Expand Up @@ -175,7 +175,7 @@ func (r *Reader) inodeRef(i uint32) (uint64, error) {
// Populate the export table as needed
var blockNum uint32
if i != 0 { // If i == 0, we go negatives causing issues with uint32s
blockNum = uint32(math.Ceil(float64(i)/1024)) - 1
blockNum = uint32(math.Ceil(float64(i+1)/1024)) - 1
} else {
blockNum = 0
}
Expand Down

0 comments on commit b93b36f

Please sign in to comment.