Skip to content

PgpPublicKey.RemoveCert can delete wrong items. #546

@tohidemyname

Description

@tohidemyname

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions