for (i = 0; i < count; i ++)
{
- const SecCertificateRef secCert = CFArrayGetValueAtIndex(secArray, i);
+ SecCertificateRef secCert = (SecCertificateRef)CFArrayGetValueAtIndex(secArray, i);
#ifdef DEBUG
CFStringRef cf_name = SecCertificateCopySubjectSummary(secCert);
cups_array_t *credentials, /* I - Credentials */
const char *common_name) /* I - Common name for credentials */
{
- int ret = -1; /* Return value */
+ int ret = 0; /* Return value */
OSStatus err; /* Error info */
#if TARGET_OS_OSX
char filename[1024]; /* Filename for keychain */
DEBUG_printf(("httpSaveCredentials(path=\"%s\", credentials=%p, common_name=\"%s\")", path, (void *)credentials, common_name));
if (!credentials)
- goto cleanup;
+ {
+ DEBUG_puts("1httpSaveCredentials: No credentials, returning -1.");
+ return (-1);
+ }
if (!httpCredentialsAreValidForName(credentials, common_name))
{
keychain = http_cdsa_open_keychain(path, filename, sizeof(filename));
if (!keychain)
- goto cleanup;
+ {
+ DEBUG_puts("1httpSaveCredentials: No keychain, returning -1.");
+ return (-1);
+ }
#else
if (path)
+ {
+ DEBUG_puts("1httpSaveCredentials: No path, returning -1.");
return (-1);
+ }
#endif /* TARGET_OS_OSX */
if ((attrs = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)) == NULL)
if ((list = CFArrayCreate(kCFAllocatorDefault, (const void **)&keychain, 1, &kCFTypeArrayCallBacks)) == NULL)
{
DEBUG_puts("1httpSaveCredentials: Unable to create list of keychains.");
+ ret = -1;
goto cleanup;
}
CFDictionaryAddValue(attrs, kSecMatchSearchList, list);
#endif /* TARGET_OS_OSX */
/* Note: SecItemAdd consumes "attrs"... */
- err = SecItemAdd(attrs, NULL);
- DEBUG_printf(("1httpSaveCredentials: SecItemAdd returned %d.", (int)err));
+ if((err = SecItemAdd(attrs, NULL)) != 0)
+ {
+ DEBUG_printf(("1httpSaveCredentials: SecItemAdd failed, returned %d.", (int)err));
+ ret = -1;
+ }
cleanup :
#if TARGET_OS_OSX
- if (keychain)
- CFRelease(keychain);
+ CFRelease(keychain);
#endif /* TARGET_OS_OSX */
- if (cert)
- CFRelease(cert);
+ CFRelease(cert);
DEBUG_printf(("1httpSaveCredentials: Returning %d.", ret));