[vlc-commits] keychain: Fix storing of new keychain item on older macOS versions

David Fuhrmann git at videolan.org
Thu Apr 19 01:09:04 CEST 2018


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Thu Apr 19 01:03:09 2018 +0200| [eb44067d0b9a260d32df0b3026f4cdb566cf2296] | committer: David Fuhrmann

keychain: Fix storing of new keychain item on older macOS versions

Older versions are more picky regarding SecItemCopyMatching.
According to docu, one output type must be given, and also an actual
output variable must be passed (as tests show). Only then,
a 10.7 system accepts that search call.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=eb44067d0b9a260d32df0b3026f4cdb566cf2296
---

 modules/keystore/keychain.m | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/modules/keystore/keychain.m b/modules/keystore/keychain.m
index 991651497b..e8c3ee98fa 100644
--- a/modules/keystore/keychain.m
+++ b/modules/keystore/keychain.m
@@ -291,9 +291,13 @@ static int Store(vlc_keystore *p_keystore,
     /* set attributes */
     SetAttributesForQuery(ppsz_values, searchQuery, psz_label);
 
-    /* search */
-    status = SecItemCopyMatching((__bridge CFDictionaryRef)searchQuery, nil);
+    // One return type must be added for SecItemCopyMatching, even if not used.
+    // Older macOS versions (10.7) are very picky here...
+    [searchQuery setObject:@(YES) forKey:(__bridge id)kSecReturnRef];
+    CFTypeRef result = NULL;
 
+    /* search */
+    status = SecItemCopyMatching((__bridge CFDictionaryRef)searchQuery, &result);
     /* create storage unit */
     NSData *secretData = [[NSString stringWithFormat:@"%s", p_secret] dataUsingEncoding:NSUTF8StringEncoding];
 



More information about the vlc-commits mailing list