diff --git a/bbootimg/src/main/kotlin/bootimg/v2/BootV2.kt b/bbootimg/src/main/kotlin/bootimg/v2/BootV2.kt index da089ee..509ed6b 100644 --- a/bbootimg/src/main/kotlin/bootimg/v2/BootV2.kt +++ b/bbootimg/src/main/kotlin/bootimg/v2/BootV2.kt @@ -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) diff --git a/bbootimg/src/main/kotlin/bootimg/v3/BootV3.kt b/bbootimg/src/main/kotlin/bootimg/v3/BootV3.kt index f5d69da..9f62bed 100644 --- a/bbootimg/src/main/kotlin/bootimg/v3/BootV3.kt +++ b/bbootimg/src/main/kotlin/bootimg/v3/BootV3.kt @@ -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) diff --git a/helper/src/test/kotlin/cfig/helper/OpenSslHelperTest.kt b/helper/src/test/kotlin/cfig/helper/OpenSslHelperTest.kt index ecabca9..bfaa568 100644 --- a/helper/src/test/kotlin/cfig/helper/OpenSslHelperTest.kt +++ b/helper/src/test/kotlin/cfig/helper/OpenSslHelperTest.kt @@ -106,5 +106,10 @@ class OpenSslHelperTest { this.generate(pk1, crt) } pfx.toJks().writeTo("platform.jks") + File("platform.jks").let { + if (it.exists()) { + it.delete() + } + } } }