Catch SecurityException when opening URIs during decrypt

This commit is contained in:
Vincent Breitmoser
2018-06-14 14:24:47 +02:00
parent 0ef46ecb81
commit 700e06dcb9
3 changed files with 8 additions and 1 deletions

View File

@@ -648,6 +648,7 @@ public abstract class OperationResult implements Parcelable {
MSG_DC_ERROR_INVALID_DATA (LogLevel.ERROR, R.string.msg_dc_error_invalid_data),
MSG_DC_ERROR_IO (LogLevel.ERROR, R.string.msg_dc_error_io),
MSG_DC_ERROR_INPUT (LogLevel.ERROR, R.string.msg_dc_error_input),
MSG_DC_ERROR_INPUT_DENIED (LogLevel.ERROR, R.string.msg_dc_error_input_denied),
MSG_DC_ERROR_NO_DATA (LogLevel.ERROR, R.string.msg_dc_error_no_data),
MSG_DC_ERROR_NO_KEY (LogLevel.ERROR, R.string.msg_dc_error_no_key),
MSG_DC_ERROR_NO_SIGNATURE (LogLevel.ERROR, R.string.msg_dc_error_no_signature),

View File

@@ -115,8 +115,13 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
InputStream inputStream = mContext.getContentResolver().openInputStream(input.getInputUri());
long inputSize = FileHelper.getFileSize(mContext, input.getInputUri(), 0);
inputData = new InputData(inputStream, inputSize);
} catch (SecurityException e) {
Timber.e(e, "Access denied for input URI: %s", input.getInputUri());
OperationLog log = new OperationLog();
log.add(LogType.MSG_DC_ERROR_INPUT_DENIED, 1);
return new DecryptVerifyResult(DecryptVerifyResult.RESULT_ERROR, log);
} catch (FileNotFoundException e) {
Timber.e(e, "Input URI could not be opened: " + input.getInputUri());
Timber.e(e, "Input URI could not be opened: %s", input.getInputUri());
OperationLog log = new OperationLog();
log.add(LogType.MSG_DC_ERROR_INPUT, 1);
return new DecryptVerifyResult(DecryptVerifyResult.RESULT_ERROR, log);