Issue #57: allocate proper buffer size for BootV2/V3 images

use the maxOf(image size, 64MB)
pull/66/head
cfig 4 years ago
parent d49b9b47a1
commit ec13a2d926
No known key found for this signature in database
GPG Key ID: B104C307F0FDABB7

@ -383,7 +383,8 @@ data class BootV2(
}
log.info("Writing data ...")
val bytesV2 = ByteBuffer.allocate(1024 * 1024 * 64)//assume total SIZE small than 64MB
//boot image size may > 64MB. Fix issue #57
val bytesV2 = ByteBuffer.allocate(maxOf(1024 * 1024 * 64, info.imageSize.toInt()))
.let { bf ->
bf.order(ByteOrder.LITTLE_ENDIAN)
Common.writePaddedFile(bf, kernel.file!!, info.pageSize)

@ -111,7 +111,8 @@ data class BootV3(
//data
log.info("Writing data ...")
val bf = ByteBuffer.allocate(1024 * 1024 * 96)//assume total SIZE small than 96MB
//BootV3 should have correct image size
val bf = ByteBuffer.allocate(maxOf(info.imageSize.toInt(), 64 *1024 *1024))
bf.order(ByteOrder.LITTLE_ENDIAN)
C.writePaddedFile(bf, this.kernel.file, this.info.pageSize)
C.writePaddedFile(bf, this.ramdisk.file, this.info.pageSize)

@ -106,5 +106,10 @@ class OpenSslHelperTest {
this.generate(pk1, crt)
}
pfx.toJks().writeTo("platform.jks")
File("platform.jks").let {
if (it.exists()) {
it.delete()
}
}
}
}

Loading…
Cancel
Save