diff --git a/app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt b/app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt index fe0766754..f716e042b 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt @@ -188,10 +188,15 @@ abstract class MagiskInstallImpl protected constructor( val name = entry.name.replace(".lz4", "") console.add("-- Extracting: $name") - val extract = File(installDir, name) - extract.outputStream().use { decompressedStream().copyTo(it) } + val extract = installDirFile(name) + SuFileOutputStream(extract).use { decompressedStream().copyTo(it) } } else if (entry.name.contains("vbmeta.img")) { - val rawData = decompressedStream().readBytes() + // DO NOT USE readBytes() DUE TO BUG IN LZ4FrameInputStream + val rawData = decompressedStream().run { + val buffer = ByteArrayOutputStream() + copyTo(buffer) + buffer.toByteArray() + } // Valid vbmeta.img should be at least 256 bytes if (rawData.size < 256) continue @@ -264,9 +269,10 @@ abstract class MagiskInstallImpl protected constructor( handleTar(src, outFile!!.uri.outputStream()) } else { // Raw image - srcBoot = File(installDir, "boot.img").path + val image = installDirFile("boot.img") + srcBoot = image.path console.add("- Copying image to cache") - FileOutputStream(srcBoot).use { src.copyTo(it) } + SuFileOutputStream(image).use { src.copyTo(it) } outFile = MediaStoreUtils.getFile("$filename.img", true) outFile!!.uri.outputStream() } diff --git a/gradle.properties b/gradle.properties index 234f3da65..29ac4f4a6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -28,6 +28,6 @@ kapt.incremental.apt=true # Magisk magisk.stubVersion=16 -magisk.versionCode=21403 +magisk.versionCode=21404 magisk.ndkVersion=21d magisk.fullNdkVersion=21.3.6528147