Support tar with files larger than 8GiB

Fix #7838
This commit is contained in:
topjohnwu 2024-03-14 16:54:46 -07:00
parent c951b208a1
commit 81658d45f7
2 changed files with 9 additions and 10 deletions

View File

@ -70,7 +70,7 @@ configurations.all {
dependencies { dependencies {
implementation(project(":app:shared")) implementation(project(":app:shared"))
implementation("com.github.topjohnwu:jtar:1.0.0") implementation("com.github.topjohnwu:jtar:1.1.0")
implementation("com.github.topjohnwu:indeterminate-checkbox:1.0.7") implementation("com.github.topjohnwu:indeterminate-checkbox:1.0.7")
implementation("com.github.topjohnwu:lz4-java:1.7.1") implementation("com.github.topjohnwu:lz4-java:1.7.1")
implementation("com.jakewharton.timber:timber:5.0.1") implementation("com.jakewharton.timber:timber:5.0.1")

View File

@ -17,8 +17,8 @@ import com.topjohnwu.magisk.core.Const
import com.topjohnwu.magisk.core.Info import com.topjohnwu.magisk.core.Info
import com.topjohnwu.magisk.core.di.ServiceLocator import com.topjohnwu.magisk.core.di.ServiceLocator
import com.topjohnwu.magisk.core.isRunningAsStub import com.topjohnwu.magisk.core.isRunningAsStub
import com.topjohnwu.magisk.core.ktx.copyAndClose
import com.topjohnwu.magisk.core.ktx.copyAll import com.topjohnwu.magisk.core.ktx.copyAll
import com.topjohnwu.magisk.core.ktx.copyAndClose
import com.topjohnwu.magisk.core.ktx.reboot import com.topjohnwu.magisk.core.ktx.reboot
import com.topjohnwu.magisk.core.ktx.toast import com.topjohnwu.magisk.core.ktx.toast
import com.topjohnwu.magisk.core.ktx.writeTo import com.topjohnwu.magisk.core.ktx.writeTo
@ -380,17 +380,16 @@ abstract class MagiskInstallImpl protected constructor(
// Process input file // Process input file
try { try {
uri.inputStream().buffered().use { src -> PushbackInputStream(uri.inputStream(), 512).use { src ->
src.mark(500) val head = ByteArray(512)
val magic = ByteArray(4) if (src.read(head) != head.size) {
val tarMagic = ByteArray(5)
if (src.read(magic) != magic.size || src.skip(253) != 253L ||
src.read(tarMagic) != tarMagic.size
) {
console.add("! Invalid input file") console.add("! Invalid input file")
return false return false
} }
src.reset() src.unread(head)
val magic = head.copyOf(4)
val tarMagic = Arrays.copyOfRange(head, 257, 262)
val alpha = "abcdefghijklmnopqrstuvwxyz" val alpha = "abcdefghijklmnopqrstuvwxyz"
val alphaNum = "$alpha${alpha.uppercase(Locale.ROOT)}0123456789" val alphaNum = "$alpha${alpha.uppercase(Locale.ROOT)}0123456789"