fix fromStream method, properly recognize multiple concatenated streams

This commit is contained in:
Vincent Breitmoser 2014-07-31 19:27:01 +02:00
parent b40081c364
commit acb5a70e44

View File

@ -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,11 +135,9 @@ public class UncachedKeyRing {
}
try {
while(stream.available() > 0) {
// if there are no objects left from the last factory, create a new one
if (mObjectFactory == null) {
if (stream.available() == 0) {
// end of stream. that's fine
return;
}
mObjectFactory = new PGPObjectFactory(PGPUtil.getDecoderStream(stream));
}
@ -154,6 +154,9 @@ public class UncachedKeyRing {
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);
}