diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-01-02 01:57:49 +0100 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-01-02 01:58:16 +0100 |
commit | b52fb903803c2dfca578c140dfdc776927c6fc4b (patch) | |
tree | 6bae0cdc0b31b9a5e2f51a8af3374f378efa3618 /OpenKeychain/src/main/java | |
parent | 704fc2dd45f20c7edc68b2930e2a73179d5fbdae (diff) | |
download | open-keychain-b52fb903803c2dfca578c140dfdc776927c6fc4b.tar.gz open-keychain-b52fb903803c2dfca578c140dfdc776927c6fc4b.tar.bz2 open-keychain-b52fb903803c2dfca578c140dfdc776927c6fc4b.zip |
fix and test for bad certificate version numbers (#1012)
closes #1012
Diffstat (limited to 'OpenKeychain/src/main/java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java | 20 |
1 files changed, 13 insertions, 7 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 c4cd0b3e5..006af6073 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java @@ -143,17 +143,22 @@ public class UncachedKeyRing { throw new PgpGeneralException("Object not recognized as PGPKeyRing!"); } - UncachedKeyRing ring = parsed.next(); + try { + UncachedKeyRing ring = parsed.next(); - if (parsed.hasNext()) { - throw new PgpGeneralException("Expected single keyring in stream, found at least two"); - } + if (parsed.hasNext()) { + throw new PgpGeneralException("Expected single keyring in stream, found at least two"); + } - return ring; + return ring; + } catch (RuntimeException e) { + // yes this is bad style. we should rework this in a better way + throw new PgpGeneralException(e.getCause()); + } } - public static Iterator<UncachedKeyRing> fromStream(final InputStream stream) throws IOException { + public static Iterator<UncachedKeyRing> fromStream(final InputStream stream) { return new Iterator<UncachedKeyRing>() { @@ -190,7 +195,8 @@ public class UncachedKeyRing { mObjectFactory = null; } } catch (IOException e) { - Log.e(Constants.TAG, "IOException while processing stream. ArmoredInputStream CRC check failed?", e); + throw new RuntimeException(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); } |