From b93b36f3632842a0cca89fd7c9e3d21ac4692334 Mon Sep 17 00:00:00 2001 From: Will Murphy Date: Wed, 27 Nov 2024 06:50:03 -0500 Subject: [PATCH] fix: stop index out of range on block boundaries Pulls in changes from 03266d056023d5c28087540eeec835c687cc482c in upstream, without intermediate changes, and without stray println. --- low/reader.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/low/reader.go b/low/reader.go index 3755841..d040316 100644 --- a/low/reader.go +++ b/low/reader.go @@ -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 } @@ -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 } @@ -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 }