fix(import/OVA): fix big size parsing in OVA files (#5129)
This commit is contained in:
parent
6beefe86e2
commit
f580e0d26f
@ -17,6 +17,7 @@
|
||||
|
||||
- [Restore legacy, File restore legacy] Fix mount error in case of existing proxy remotes (PR [#5124](https://github.com/vatesfr/xen-orchestra/pull/5124))
|
||||
- [File restore] Don't fail with `TypeError [ERR_INVALID_ARG_TYPE]` on LVM partitions
|
||||
- [Import/OVA] Fix import of bigger OVA files (>8GB .vmdk disk) (PR [#5129](https://github.com/vatesfr/xen-orchestra/pull/5129))
|
||||
|
||||
### Packages to release
|
||||
|
||||
@ -35,5 +36,6 @@
|
||||
>
|
||||
> In case of conflict, the highest (lowest in previous list) `$version` wins.
|
||||
|
||||
- xo-vmdk-to-vhd patch
|
||||
- xo-server minor
|
||||
- xo-web minor
|
||||
|
@ -67,10 +67,21 @@ function parseTarHeader(header, stringDeserializer) {
|
||||
if (fileName.length === 0) {
|
||||
return null
|
||||
}
|
||||
const fileSize = parseInt(
|
||||
stringDeserializer(header.slice(124, 124 + 11), 'ascii'),
|
||||
8
|
||||
)
|
||||
const sizeBuffer = header.slice(124, 124 + 12)
|
||||
// size encoding: https://codeistry.wordpress.com/2014/08/14/how-to-parse-a-tar-file/
|
||||
let fileSize = 0
|
||||
// If the leading byte is 0x80 (128), the non-leading bytes of the field are concatenated in big-endian order, with the result being a positive number expressed in binary form.
|
||||
//
|
||||
// Source: https://www.gnu.org/software/tar/manual/html_node/Extensions.html
|
||||
if (new Uint8Array(sizeBuffer)[0] === 128) {
|
||||
for (const byte of new Uint8Array(sizeBuffer.slice(1))) {
|
||||
fileSize *= 256
|
||||
fileSize += byte
|
||||
}
|
||||
} else {
|
||||
fileSize = parseInt(stringDeserializer(sizeBuffer.slice(0, 11), 'ascii'), 8)
|
||||
}
|
||||
|
||||
return { fileName, fileSize }
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user