formats
formats copied to clipboard
der: SetOfVec::insert can break the structure on error
The way SetOfVec::insert is implemented results in the internal structure containing an unsorted duplicate value, because it first inserts the value, and then check whether it's a dupe while simultaneously sorting it:
-
SetOfVec::insert: https://github.com/RustCrypto/formats/blob/master/der/src/asn1/set_of.rs#L268-L271 -
der_sort: https://github.com/RustCrypto/formats/blob/master/der/src/asn1/set_of.rs#L456-L473
Could der_sort perhaps remove the duplicate so the structure is still valid in case the insert function returns an error?