consistently use FileHelper.openInputStreamSafe to resolve input streams

This commit is contained in:
Vincent Breitmoser
2024-01-29 10:34:51 +01:00
parent 034eab9df1
commit ba9c93d046
8 changed files with 18 additions and 14 deletions

View File

@@ -41,6 +41,7 @@ import org.sufficientlysecure.keychain.ui.util.recyclerview.ItemTouchHelperAdapt
import org.sufficientlysecure.keychain.ui.util.recyclerview.ItemTouchHelperDragCallback;
import org.sufficientlysecure.keychain.ui.util.recyclerview.ItemTouchHelperViewHolder;
import org.sufficientlysecure.keychain.ui.util.recyclerview.RecyclerItemClickListener;
import org.sufficientlysecure.keychain.util.FileHelper;
import java.io.IOException;
import java.io.InputStream;
@@ -205,7 +206,7 @@ public class SettingsSmartPGPAuthorityFragment extends Fragment implements Recyc
if (uri == null) {
new_cert = old_cert;
} else {
final InputStream fis = getContext().getContentResolver().openInputStream(Uri.parse(uri));
final InputStream fis = FileHelper.openInputStreamSafe(getContext().getContentResolver(), Uri.parse(uri));
final CertificateFactory cf = CertificateFactory.getInstance("X.509");
new_cert = cf.generateCertificate(fis);

View File

@@ -47,6 +47,7 @@ import org.sufficientlysecure.keychain.pgp.UncachedKeyRing.IteratorWithIOThrow;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.securitytoken.SecurityTokenInfo;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.util.FileHelper;
import org.sufficientlysecure.keychain.util.ParcelableProxy;
import org.sufficientlysecure.keychain.util.Preferences;
import timber.log.Timber;
@@ -206,7 +207,7 @@ public class PublicKeyRetriever {
log.add(LogType.MSG_RET_CURI_START, 0);
log.add(LogType.MSG_RET_CURI_OPEN, 1, uri.toString());
InputStream is = context.getContentResolver().openInputStream(uri);
InputStream is = FileHelper.openInputStreamSafe(context.getContentResolver(), uri);
if (is == null) {
log.add(LogType.MSG_RET_CURI_ERROR_NOT_FOUND, 1);
return KeyRetrievalResult.createWithError(log);