mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-01-12 22:18:11 -05:00
getSignaturesForID can return null, check this
This commit is contained in:
parent
40c81c9429
commit
aca9ecdb85
@ -375,9 +375,11 @@ public class UncachedKeyRing {
|
|||||||
PGPSignature selfCert = null;
|
PGPSignature selfCert = null;
|
||||||
revocation = null;
|
revocation = null;
|
||||||
|
|
||||||
// look through signatures for this specific key
|
// look through signatures for this specific user id
|
||||||
for (PGPSignature zert : new IterableIterator<PGPSignature>(
|
@SuppressWarnings("unchecked")
|
||||||
masterKey.getSignaturesForID(userId))) {
|
Iterator<PGPSignature> signaturesIt = masterKey.getSignaturesForID(userId);
|
||||||
|
if (signaturesIt != null) {
|
||||||
|
for (PGPSignature zert : new IterableIterator<PGPSignature>(signaturesIt)) {
|
||||||
WrappedSignature cert = new WrappedSignature(zert);
|
WrappedSignature cert = new WrappedSignature(zert);
|
||||||
long certId = cert.getKeyId();
|
long certId = cert.getKeyId();
|
||||||
|
|
||||||
@ -496,9 +498,8 @@ public class UncachedKeyRing {
|
|||||||
redundantCerts += 1;
|
redundantCerts += 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no valid certificate (if only a revocation) remains, drop it
|
// If no valid certificate (if only a revocation) remains, drop it
|
||||||
@ -510,7 +511,7 @@ public class UncachedKeyRing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If NO user ids remain, error out!
|
// If NO user ids remain, error out!
|
||||||
if (!modified.getUserIDs().hasNext()) {
|
if (modified == null || !modified.getUserIDs().hasNext()) {
|
||||||
log.add(LogLevel.ERROR, LogType.MSG_KC_ERROR_NO_UID, indent);
|
log.add(LogLevel.ERROR, LogType.MSG_KC_ERROR_NO_UID, indent);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -817,7 +818,13 @@ public class UncachedKeyRing {
|
|||||||
|
|
||||||
// Copy over all user id certificates
|
// Copy over all user id certificates
|
||||||
for (String userId : new IterableIterator<String>(key.getUserIDs())) {
|
for (String userId : new IterableIterator<String>(key.getUserIDs())) {
|
||||||
for (PGPSignature cert : new IterableIterator<PGPSignature>(key.getSignaturesForID(userId))) {
|
@SuppressWarnings("unchecked")
|
||||||
|
Iterator<PGPSignature> signaturesIt = key.getSignaturesForID(userId);
|
||||||
|
// no signatures for this User ID, skip it
|
||||||
|
if (signaturesIt == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (PGPSignature cert : new IterableIterator<PGPSignature>(signaturesIt)) {
|
||||||
// Don't merge foreign stuff into secret keys
|
// Don't merge foreign stuff into secret keys
|
||||||
if (cert.getKeyID() != masterKeyId && isSecret()) {
|
if (cert.getKeyID() != masterKeyId && isSecret()) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -128,10 +128,18 @@ public class UncachedPublicKey {
|
|||||||
public String getPrimaryUserId() {
|
public String getPrimaryUserId() {
|
||||||
String found = null;
|
String found = null;
|
||||||
PGPSignature foundSig = null;
|
PGPSignature foundSig = null;
|
||||||
|
// noinspection unchecked
|
||||||
for (String userId : new IterableIterator<String>(mPublicKey.getUserIDs())) {
|
for (String userId : new IterableIterator<String>(mPublicKey.getUserIDs())) {
|
||||||
PGPSignature revocation = null;
|
PGPSignature revocation = null;
|
||||||
|
|
||||||
for (PGPSignature sig : new IterableIterator<PGPSignature>(mPublicKey.getSignaturesForID(userId))) {
|
@SuppressWarnings("unchecked")
|
||||||
|
Iterator<PGPSignature> signaturesIt = mPublicKey.getSignaturesForID(userId);
|
||||||
|
// no signatures for this User ID
|
||||||
|
if (signaturesIt == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (PGPSignature sig : new IterableIterator<PGPSignature>(signaturesIt)) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// if this is a revocation, this is not the user id
|
// if this is a revocation, this is not the user id
|
||||||
@ -314,6 +322,7 @@ public class UncachedPublicKey {
|
|||||||
|
|
||||||
public Iterator<WrappedSignature> getSignaturesForId(String userId) {
|
public Iterator<WrappedSignature> getSignaturesForId(String userId) {
|
||||||
final Iterator<PGPSignature> it = mPublicKey.getSignaturesForID(userId);
|
final Iterator<PGPSignature> it = mPublicKey.getSignaturesForID(userId);
|
||||||
|
if (it != null) {
|
||||||
return new Iterator<WrappedSignature>() {
|
return new Iterator<WrappedSignature>() {
|
||||||
public void remove() {
|
public void remove() {
|
||||||
it.remove();
|
it.remove();
|
||||||
@ -325,6 +334,9 @@ public class UncachedPublicKey {
|
|||||||
return it.hasNext();
|
return it.hasNext();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user