aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-08-16 05:13:09 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2014-08-16 06:53:50 +0200
commitc54fe21f44f118c59874fe97b662b3faea6ebc48 (patch)
treea3da875b766cd32ef9b15f44c14581967a782a67 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java
parent0708b573fc7a058d08840b8ce256cb103a0eeafa (diff)
downloadopen-keychain-c54fe21f44f118c59874fe97b662b3faea6ebc48.tar.gz
open-keychain-c54fe21f44f118c59874fe97b662b3faea6ebc48.tar.bz2
open-keychain-c54fe21f44f118c59874fe97b662b3faea6ebc48.zip
modifySecretKey: err out on revocation of nonexistent user id
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java
index fe84b3802..06d8dff69 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java
@@ -403,6 +403,18 @@ public class PgpKeyOperation {
progress(R.string.progress_modify_revokeuid, (i-1) * (100 / saveParcel.mRevokeUserIds.size()));
String userId = saveParcel.mRevokeUserIds.get(i);
log.add(LogLevel.INFO, LogType.MSG_MF_UID_REVOKE, indent, userId);
+ // Make sure the user id exists (yes these are 10 LoC in Java!)
+ boolean exists = false;
+ for (String uid : new IterableIterator<String>(modifiedPublicKey.getUserIDs())) {
+ if (userId.equals(uid)) {
+ exists = true;
+ break;
+ }
+ }
+ if (!exists) {
+ log.add(LogLevel.ERROR, LogType.MSG_MF_ERROR_NOEXIST_REVOKE, indent);
+ return new EditKeyResult(EditKeyResult.RESULT_ERROR, log, null);
+ }
// a duplicate revocation will be removed during canonicalization, so no need to
// take care of that here.