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);

View File

@@ -1204,6 +1204,7 @@
<string name="msg_dc_error_invalid_data">"No valid OpenPGP encrypted or signed data found!"</string>
<string name="msg_dc_error_io">"Encountered an error reading input data!"</string>
<string name="msg_dc_error_input">"Error opening input data stream!"</string>
<string name="msg_dc_error_input_denied">"Error opening input data stream: access denied!"</string>
<string name="msg_dc_error_no_data">"No encrypted data found in stream!"</string>
<string name="msg_dc_error_no_key">"No encrypted data with known secret key found in stream!"</string>
<string name="msg_dc_error_no_signature">"Missing signature data!"</string>