File tree Expand file tree Collapse file tree 1 file changed +20
-11
lines changed Expand file tree Collapse file tree 1 file changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -250,17 +250,26 @@ impl Keyring {
250250 )
251251 } ) ?;
252252 unsafe { buffer. set_len ( ( actual_sz as usize ) / mem:: size_of :: < KeyringSerial > ( ) ) } ;
253- let keys = buffer
254- . iter ( )
255- . map ( |& id| Key :: new_impl ( id) )
256- . partition ( |key| key. description ( ) . unwrap ( ) . type_ == keytypes:: Keyring :: name ( ) ) ;
257- Ok ( (
258- keys. 1 ,
259- keys. 0
260- . iter ( )
261- . map ( |key| Keyring :: new_impl ( key. id ) )
262- . collect :: < Vec < _ > > ( ) ,
263- ) )
253+
254+ let mut keys = Vec :: new ( ) ;
255+ let mut keyrings = Vec :: new ( ) ;
256+ for key in buffer. into_iter ( ) . map ( |id| Key :: new_impl ( id) ) {
257+ match key. description ( ) {
258+ Ok ( description) => {
259+ if description. type_ == keytypes:: Keyring :: name ( ) {
260+ keyrings. push ( Keyring :: new_impl ( key. id ) )
261+ } else {
262+ keys. push ( key)
263+ }
264+ } ,
265+ // Keys can be invalidated between reading the keyring and
266+ // reading the child key's description. If this happens, we get
267+ // ENOKEY and just skip that key.
268+ Err ( errno:: Errno ( libc:: ENOKEY ) ) => { } ,
269+ Err ( e) => return Err ( e) ,
270+ }
271+ }
272+ Ok ( ( keys, keyrings) )
264273 }
265274
266275 /// Attach the persistent keyring for the current user to the current keyring.
You can’t perform that action at this time.
0 commit comments