fix(vhd-lib/createStreamNbd): fix off by one block length computation

This commit is contained in:
Florent Beauchamp 2023-12-20 13:21:31 +00:00 committed by Julien Fontanet
parent 77b14a316f
commit 5d80a58754
2 changed files with 3 additions and 2 deletions

View File

@ -28,6 +28,7 @@
<!--packages-start-->
- vhd-lib patch
- xo-server minor
- xo-web minor

View File

@ -81,14 +81,14 @@ exports.createNbdVhdStream = async function createVhdStream(
const entry = streamBat.readUInt32BE(i * 4)
if (entry !== BLOCK_UNUSED) {
bat.writeUInt32BE(offsetSector, i * 4)
offsetSector += blockSizeInSectors
entries.push(i)
offsetSector += blockSizeInSectors
} else {
bat.writeUInt32BE(BLOCK_UNUSED, i * 4)
}
}
const totalLength = (offsetSector + blockSizeInSectors + 1) /* end footer */ * SECTOR_SIZE
const totalLength = (offsetSector + 1) /* end footer */ * SECTOR_SIZE
let lengthRead = 0
let lastUpdate = 0