Ignore:
Timestamp:
Aug 30, 2014, 10:49:53 AM (5 years ago)
Author:
cal@…
Message:

certsync: Fix warnings and potential crash on Tiger

https://lists.macosforge.org/pipermail/macports-dev/2014-August/027807.html

Location:
trunk/dports/security/certsync/files
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/dports/security/certsync/files/certsync.m

    r124889 r124891  
    404404         * ValidateSystemTrust to use the user's keychain */
    405405        if ((err = SecKeychainSetPreferenceDomain(kSecPreferencesDomainUser)) != errSecSuccess) {
    406             CFStringRef errMsg = PLCFAutorelease(SecCopyErrorMessageString(err, NULL));
    407             nsfprintf(stderr, @"Failed to set keychain preference domain: %@\n", errMsg);
     406            if (SecCopyErrorMessageString != NULL) {
     407                /* >= 10.5 */
     408                CFStringRef errMsg = PLCFAutorelease(SecCopyErrorMessageString(err, NULL));
     409                nsfprintf(stderr, @"Failed to set keychain preference domain: %@\n", errMsg);
     410            } else {
     411                /* <= 10.4 */
     412                nsfprintf(stderr, @"Failed to set keychain preference domain: %d\n", err);
     413            }
    408414
    409415            [pool release];
     
    424430    /* Causes ValidateSystemTrust to ignore the user's keychain */
    425431    if ((err = SecKeychainSetPreferenceDomain(kSecPreferencesDomainSystem)) != errSecSuccess) {
    426         CFStringRef errMsg = PLCFAutorelease(SecCopyErrorMessageString(err, NULL));
    427         nsfprintf(stderr, @"Failed to set keychain preference domain: %@\n", errMsg);
     432        if (SecCopyErrorMessageString != NULL) {
     433            /* >= 10.5 */
     434            CFStringRef errMsg = PLCFAutorelease(SecCopyErrorMessageString(err, NULL));
     435            nsfprintf(stderr, @"Failed to set keychain preference domain: %@\n", errMsg);
     436        } else {
     437            /* <= 10.4 */
     438            nsfprintf(stderr, @"Failed to set keychain preference domain: %d\n", err);
     439        }
    428440
    429441        [pool release];
  • trunk/dports/security/certsync/files/compat.h

    r124828 r124891  
    5555    extern OSStatus SecTrustSettingsCopyCertificates (SecTrustSettingsDomain domain, CFArrayRef *certArray) __attribute__((weak_import));
    5656    #define SecTrustSettingsCopyCertificates ((OSStatus(*)(SecTrustSettingsDomain, CFArrayRef *)) NULL) /* We can't safely weak-link what we don't have */
     57
     58    /* SecTrustSettingsCopyTrustSettings() was added in 10.5 */
     59    extern OSStatus SecTrustSettingsCopyTrustSettings (SecCertificateRef certRef, SecTrustSettingsDomain domain, CFArrayRef *trustSettings) __attribute__((weak_import));
     60    #define SecTrustSettingsCopyTrustSettings ((OSStatus(*)(SecCertificateRef, SecTrustSettingsDomain, CFArrayRef *)) NULL) /* We can't safely weak-link what we don't have */
     61
     62    extern CFStringRef SecCopyErrorMessageString (OSStatus status, void *reserved) __attribute__((weak_import));
     63    #define SecCopyErrorMessageString ((CFStringRef(*)(OSStatus, void *)) NULL) /* We can't safely weak-link what we don't have */
    5764   
    5865    /* CFError was added in 10.5 */
Note: See TracChangeset for help on using the changeset viewer.