mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 19:22:14 -05:00
fix fromStream method, properly recognize multiple concatenated streams
This commit is contained in:
parent
b40081c364
commit
acb5a70e44
@ -27,9 +27,11 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
@ -133,26 +135,27 @@ public class UncachedKeyRing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (mObjectFactory == null) {
|
while(stream.available() > 0) {
|
||||||
if (stream.available() == 0) {
|
// if there are no objects left from the last factory, create a new one
|
||||||
// end of stream. that's fine
|
if (mObjectFactory == null) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
mNext = new UncachedKeyRing((PGPKeyRing) obj);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mObjectFactory = new PGPObjectFactory(PGPUtil.getDecoderStream(stream));
|
// if we are past the while loop, that means the objectFactory had no next
|
||||||
}
|
mObjectFactory = null;
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(Constants.TAG, "IOException while processing stream", e);
|
Log.e(Constants.TAG, "IOException while processing stream", e);
|
||||||
|
Loading…
Reference in New Issue
Block a user