bc-csharp
bc-csharp copied to clipboard
PgpPublicKey.RemoveCert can delete wrong items.
The code is as follows:
' private static PgpPublicKey RemoveCert(PgpPublicKey key, IUserDataPacket id) { PgpPublicKey returnKey = new PgpPublicKey(key); bool found = false;
for (int i = 0; i <returnKey.ids.Count-1; i++)
{
if (id.Equals(returnKey.ids[i]))
{
found = true;
returnKey.ids.RemoveAt(i);
returnKey.idTrusts.RemoveAt(i);
returnKey.idSigs.RemoveAt(i);
}
}
return found ? returnKey : null;
}' If returnKey.ids has more than one item, the first deletion will change the indexes of returnKey.*. The follow-up deletions will delete wrong items. My pull request is as follows:
https://github.com/bcgit/bc-csharp/pull/545