aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-07-31 19:27:01 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2014-07-31 19:27:26 +0200
commitacb5a70e445351f245ef3ffa19e69315f8548ec7 (patch)
tree5b0127b3f0fc57eca8327c8a32bb7ae0cb8058ee /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
parentb40081c364210f90adf6ce38948056bbdaba3ea1 (diff)
downloadopen-keychain-acb5a70e445351f245ef3ffa19e69315f8548ec7.tar.gz
open-keychain-acb5a70e445351f245ef3ffa19e69315f8548ec7.tar.bz2
open-keychain-acb5a70e445351f245ef3ffa19e69315f8548ec7.zip
fix fromStream method, properly recognize multiple concatenated streams
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java37
1 files changed, 20 insertions, 17 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 e7229ffbd..502e3a70c 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
@@ -27,9 +27,11 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import java.util.TreeSet;
@@ -133,26 +135,27 @@ public class UncachedKeyRing {
}
try {
- if (mObjectFactory == null) {
- if (stream.available() == 0) {
- // end of stream. that's fine
- return;
+ 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));
}
- mObjectFactory = new PGPObjectFactory(PGPUtil.getDecoderStream(stream));
- }
- // go through all objects in this block
- Object obj;
- while ((obj = mObjectFactory.nextObject()) != null) {
- Log.d(Constants.TAG, "Found class: " + obj.getClass());
- if (!(obj instanceof PGPKeyRing)) {
- Log.i(Constants.TAG,
- "Skipping object of bad type " + obj.getClass().getName() + " in stream");
- // skip object
- continue;
+ // go through all objects in this block
+ Object obj;
+ while ((obj = mObjectFactory.nextObject()) != null) {
+ Log.d(Constants.TAG, "Found class: " + obj.getClass());
+ if (!(obj instanceof PGPKeyRing)) {
+ Log.i(Constants.TAG,
+ "Skipping object of bad type " + obj.getClass().getName() + " in stream");
+ // skip object
+ continue;
+ }
+ mNext = new UncachedKeyRing((PGPKeyRing) obj);
+ return;
}
- mNext = new UncachedKeyRing((PGPKeyRing) obj);
- return;
+ // if we are past the while loop, that means the objectFactory had no next
+ mObjectFactory = null;
}
} catch (IOException e) {
Log.e(Constants.TAG, "IOException while processing stream", e);