aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-10-16 13:36:21 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2014-10-16 13:36:21 +0200
commitd09d4296da2cb91a5186c570025e66939777fb95 (patch)
treec8329a7f78d6657916d4e12ec85438e397262983 /OpenKeychain/src
parent81935fe99be8dc19852e184d5af1bb14f1430f98 (diff)
downloadopen-keychain-d09d4296da2cb91a5186c570025e66939777fb95.tar.gz
open-keychain-d09d4296da2cb91a5186c570025e66939777fb95.tar.bz2
open-keychain-d09d4296da2cb91a5186c570025e66939777fb95.zip
Silently fail on import on key import with ArrayIndexOutOfBoundsException
Diffstat (limited to 'OpenKeychain/src')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java16
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/CertifyKeySpinner.java6
2 files changed, 14 insertions, 8 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
index 2b2fbf4c2..a3ddd5325 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
@@ -41,6 +41,7 @@ import org.sufficientlysecure.keychain.util.IterableIterator;
import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.Utf8Util;
+import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -160,11 +161,15 @@ public class UncachedKeyRing {
}
try {
- while(stream.available() > 0) {
+ while (stream.available() > 0) {
// if there are no objects left from the last factory, create a new one
if (mObjectFactory == null) {
- mObjectFactory = new PGPObjectFactory(PGPUtil.getDecoderStream(stream),
- new JcaKeyFingerprintCalculator());
+ InputStream in = PGPUtil.getDecoderStream(stream);
+ if (!BufferedInputStream.class.isInstance(in)) {
+ in = new BufferedInputStream(in);
+ }
+
+ mObjectFactory = new PGPObjectFactory(in, new JcaKeyFingerprintCalculator());
}
// go through all objects in this block
@@ -184,9 +189,10 @@ public class UncachedKeyRing {
mObjectFactory = null;
}
} catch (IOException e) {
- Log.e(Constants.TAG, "IOException while processing stream", e);
+ Log.e(Constants.TAG, "IOException while processing stream. ArmoredInputStream CRC check failed?", e);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ Log.e(Constants.TAG, "ArmoredInputStream decode failed, symbol is not in decodingTable!", e);
}
-
}
@Override
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/CertifyKeySpinner.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/CertifyKeySpinner.java
index 2abb3aea3..6f37f1c72 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/CertifyKeySpinner.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/CertifyKeySpinner.java
@@ -102,16 +102,16 @@ public class CertifyKeySpinner extends KeySpinner {
@Override
boolean setStatus(Context context, Cursor cursor, ImageView statusView) {
if (cursor.getInt(mIndexIsRevoked) != 0) {
- KeyFormattingUtils.setStatusImage(getContext(), statusView, null, KeyFormattingUtils.STATE_REVOKED, false);
+ KeyFormattingUtils.setStatusImage(getContext(), statusView, null, KeyFormattingUtils.STATE_REVOKED, true);
return false;
}
if (cursor.getInt(mIndexIsExpired) != 0) {
- KeyFormattingUtils.setStatusImage(getContext(), statusView, null, KeyFormattingUtils.STATE_EXPIRED, false);
+ KeyFormattingUtils.setStatusImage(getContext(), statusView, null, KeyFormattingUtils.STATE_EXPIRED, true);
return false;
}
// don't invalidate the "None" entry, which is also null!
if (cursor.getPosition() != 0 && cursor.isNull(mIndexHasCertify)) {
- KeyFormattingUtils.setStatusImage(getContext(), statusView, null, KeyFormattingUtils.STATE_UNAVAILABLE, false);
+ KeyFormattingUtils.setStatusImage(getContext(), statusView, null, KeyFormattingUtils.STATE_UNAVAILABLE, true);
return false;
}