Commit 51e40dd9 authored by Viktor De Pasquale's avatar Viktor De Pasquale Committed by John Wu

Fixed crashes caused by file exposure beyond app bounds

parent b2048379
......@@ -8,13 +8,13 @@ import android.webkit.MimeTypeMap
import android.widget.Toast
import androidx.core.app.NotificationCompat
import androidx.core.content.getSystemService
import androidx.core.net.toUri
import com.skoumal.teanity.extensions.subscribeK
import com.topjohnwu.magisk.Config
import com.topjohnwu.magisk.Const
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.data.repository.FileRepository
import com.topjohnwu.magisk.model.entity.internal.DownloadSubject
import com.topjohnwu.magisk.utils.provide
import com.topjohnwu.magisk.utils.toast
import com.topjohnwu.magisk.utils.writeToCachedFile
import com.topjohnwu.magisk.view.Notifications
......@@ -87,7 +87,8 @@ abstract class SubstrateDownloadService : Service() {
protected fun fileIntent(fileName: String): Intent {
val file = downloadsFile(fileName)
return Intent(Intent.ACTION_VIEW)
.setDataAndType(file.toUri(), file.type)
.setDataAndType(file.provide(this), file.type)
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
protected fun moveToDownloads(file: File) {
......
......@@ -91,9 +91,8 @@ fun ApplicationInfo.findAppLabel(pm: PackageManager): String {
fun Intent.startActivity(context: Context) = context.startActivity(this)
fun File.provide(): Uri {
val context: Context by inject()
return FileProvider.getUriForFile(context, "com.topjohnwu.magisk.fileprovider", this)
fun File.provide(context: Context = get()): Uri {
return FileProvider.getUriForFile(context, context.packageName + ".provider", this)
}
fun File.mv(destination: File) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment