fix(vhd-lib/createStreamNbd): skip original table offset before overwriting (#7264)

Introduced by fc1357db93
This commit is contained in:
Florent BEAUCHAMP 2023-12-26 22:29:24 +01:00 committed by GitHub
parent 74dd4c8db7
commit 72b1878254
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

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

View File

@ -45,10 +45,12 @@ exports.createNbdVhdStream = async function createVhdStream(
const bufFooter = await readChunkStrict(sourceStream, FOOTER_SIZE)
const header = unpackHeader(await readChunkStrict(sourceStream, HEADER_SIZE))
header.tableOffset = FOOTER_SIZE + HEADER_SIZE
// compute BAT in order
const batSize = Math.ceil((header.maxTableEntries * 4) / SECTOR_SIZE) * SECTOR_SIZE
// skip space between header and beginning of the table
await skipStrict(sourceStream, header.tableOffset - (FOOTER_SIZE + HEADER_SIZE))
// new table offset
header.tableOffset = FOOTER_SIZE + HEADER_SIZE
const streamBat = await readChunkStrict(sourceStream, batSize)
let offset = FOOTER_SIZE + HEADER_SIZE + batSize
// check if parentlocator are ordered