Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PgpPublicKey.RemoveCert can delete wrong items. #546

Open
tohidemyname opened this issue Jun 21, 2024 · 0 comments
Open

PgpPublicKey.RemoveCert can delete wrong items. #546

tohidemyname opened this issue Jun 21, 2024 · 0 comments

Comments

@tohidemyname
Copy link

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:

#545

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant