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

David Fuhrmann git at videolan.org
Thu Apr 19 01:11:16 CEST 2018


vlc/vlc-3.0 | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Thu Apr 19 01:03:09 2018 +0200| [c00c9758e374c49286854b9d126aa24c8e0b4d50] | 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.

(cherry picked from commit eb44067d0b9a260d32df0b3026f4cdb566cf2296)
Signed-off-by: David Fuhrmann <dfuhrmann at videolan.org>

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

 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