@@ -259,27 +259,28 @@ unsafe fn get_credentials(id: &str, flags: u32) -> Result<Vec<(String, KeyRingSe
259259 } ;
260260 let mut pcredentials: * mut PCREDENTIALW = std:: ptr:: null_mut ( ) ;
261261 let mut count = 0 ;
262- let res = CredEnumerateW ( filter, flags, & mut count, & mut pcredentials) ;
262+ let res = unsafe { CredEnumerateW ( filter, flags, & mut count, & mut pcredentials) } ;
263263 if res == 0 {
264264 return WindowsOsKeyRing :: handle_err :: < Vec < ( String , KeyRingSecret ) > > ( ) ;
265265 }
266266
267- let credentials: & [ PCREDENTIALW ] = std:: slice:: from_raw_parts_mut ( pcredentials, count as usize ) ;
267+ let credentials: & [ PCREDENTIALW ] =
268+ unsafe { std:: slice:: from_raw_parts_mut ( pcredentials, count as usize ) } ;
268269
269270 let mut found_credentials = Vec :: new ( ) ;
270271
271272 for c in credentials {
272- let cred: CREDENTIALW = * * c;
273+ let cred: CREDENTIALW = unsafe { * * c } ;
273274 let blob: * const u8 = cred. CredentialBlob ;
274275 let blob_len: usize = cred. CredentialBlobSize as usize ;
275276 let mut i = 0isize ;
276- while * cred. TargetName . offset ( i) != 0u16 {
277+ while unsafe { * cred. TargetName . offset ( i) } != 0u16 {
277278 i += 1 ;
278279 }
279- let target = std:: slice:: from_raw_parts ( cred. TargetName , i as usize ) ;
280+ let target = unsafe { std:: slice:: from_raw_parts ( cred. TargetName , i as usize ) } ;
280281 let name = OsString :: from_wide ( target) . into_string ( ) . unwrap ( ) ;
281282
282- let secret = std:: slice:: from_raw_parts ( blob, blob_len) ;
283+ let secret = unsafe { std:: slice:: from_raw_parts ( blob, blob_len) } ;
283284 let mut secret_u16 = vec ! [ 0 ; blob_len / 2 ] ;
284285 LittleEndian :: read_u16_into ( & secret, & mut secret_u16) ;
285286 let t = match String :: from_utf16 ( secret_u16. as_slice ( ) ) . map ( |pass| pass. to_string ( ) ) {
@@ -300,6 +301,6 @@ unsafe fn get_credentials(id: &str, flags: u32) -> Result<Vec<(String, KeyRingSe
300301 } ;
301302 found_credentials. push ( ( name, KeyRingSecret ( t. as_bytes ( ) . to_vec ( ) ) ) ) ;
302303 }
303- CredFree ( pcredentials as * mut c_void ) ;
304+ unsafe { CredFree ( pcredentials as * mut c_void ) } ;
304305 Ok ( found_credentials)
305306}
0 commit comments