aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/InputDataOperation.java
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-09-17 22:10:37 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2015-09-17 22:13:20 +0200
commit8ad31e32519b42c3ae439baa52716792980c5638 (patch)
tree92e1758a9783279684e4dbad290dca908829477f /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/InputDataOperation.java
parent955a1f4b2664dd548a71a343a4792bf1a4c8cfa9 (diff)
downloadopen-keychain-8ad31e32519b42c3ae439baa52716792980c5638.tar.gz
open-keychain-8ad31e32519b42c3ae439baa52716792980c5638.tar.bz2
open-keychain-8ad31e32519b42c3ae439baa52716792980c5638.zip
mime: skip trailing unsigned parts, and ignore nested signed data
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/InputDataOperation.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/InputDataOperation.java19
1 files changed, 16 insertions, 3 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/InputDataOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/InputDataOperation.java
index 56e7d822d..d9e48af8a 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/InputDataOperation.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/InputDataOperation.java
@@ -146,8 +146,8 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
@Override
public void startMultipart(BodyDescriptor bd) throws MimeException {
if ("signed".equals(bd.getSubType())) {
- if (mSignedDataResult != null) {
- // recursive signed data is not supported!
+ if (mSignedDataUri != null) {
+ // recursive signed data is not supported, and will just be parsed as-is
log.add(LogType.MSG_DATA_DETACHED_NESTED, 2);
return;
}
@@ -185,6 +185,7 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
}
out.close();
+ // continue to next body part the usual way
parser.setFlat();
}
@@ -259,6 +260,13 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
return;
}
+ // If mSignedDataUri is non-null, we already parsed a signature. If mSignedDataResult is non-null
+ // too, we are still in the same parsing stage, so this is trailing data - skip it!
+ if (mSignedDataUri != null && mSignedDataResult != null) {
+ log.add(LogType.MSG_DATA_DETACHED_TRAILING, 2);
+ return;
+ }
+
log.add(LogType.MSG_DATA_MIME_PART, 2);
log.add(LogType.MSG_DATA_MIME_TYPE, 3, bd.getMimeType());
@@ -313,8 +321,13 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
decryptResult = mSignedDataResult;
}
- in = mContext.getContentResolver().openInputStream(mSignedDataUri);
+ // the actual content is the signed data now (and will be passed verbatim, if parsing fails)
+ currentInputUri = mSignedDataUri;
+ in = mContext.getContentResolver().openInputStream(currentInputUri);
+ // reset signed data result, to indicate to the parser that it is in the inner part
+ mSignedDataResult = null;
parser.parse(in);
+
}
// if we found data, return success