Fixed crashes caused by file exposure beyond app bounds

This commit is contained in:
Viktor De Pasquale 2019-07-10 18:08:18 +02:00 committed by John Wu
parent b2048379af
commit 51e40dd98c
2 changed files with 5 additions and 5 deletions

View File

@ -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) {

View 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) {