Catch SecurityException when opening URIs during decrypt
This commit is contained in:
@@ -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_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_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 (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_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_KEY (LogLevel.ERROR, R.string.msg_dc_error_no_key),
|
||||||
MSG_DC_ERROR_NO_SIGNATURE (LogLevel.ERROR, R.string.msg_dc_error_no_signature),
|
MSG_DC_ERROR_NO_SIGNATURE (LogLevel.ERROR, R.string.msg_dc_error_no_signature),
|
||||||
|
|||||||
@@ -115,8 +115,13 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
|||||||
InputStream inputStream = mContext.getContentResolver().openInputStream(input.getInputUri());
|
InputStream inputStream = mContext.getContentResolver().openInputStream(input.getInputUri());
|
||||||
long inputSize = FileHelper.getFileSize(mContext, input.getInputUri(), 0);
|
long inputSize = FileHelper.getFileSize(mContext, input.getInputUri(), 0);
|
||||||
inputData = new InputData(inputStream, inputSize);
|
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) {
|
} 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();
|
OperationLog log = new OperationLog();
|
||||||
log.add(LogType.MSG_DC_ERROR_INPUT, 1);
|
log.add(LogType.MSG_DC_ERROR_INPUT, 1);
|
||||||
return new DecryptVerifyResult(DecryptVerifyResult.RESULT_ERROR, log);
|
return new DecryptVerifyResult(DecryptVerifyResult.RESULT_ERROR, log);
|
||||||
|
|||||||
@@ -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_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_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">"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_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_key">"No encrypted data with known secret key found in stream!"</string>
|
||||||
<string name="msg_dc_error_no_signature">"Missing signature data!"</string>
|
<string name="msg_dc_error_no_signature">"Missing signature data!"</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user