mirror of
https://github.com/moparisthebest/curl
synced 2025-01-11 22:18:00 -05:00
sectransp: fix EXC_BAD_ACCESS caused by uninitialized buffer
When the SecCertificateCopyCommonName function fails, it leaves common_name in a invalid state so CFStringCompare uses the invalid result, causing EXC_BAD_ACCESS. The fix is to check the return value of the function before using the name. Closes #7126
This commit is contained in:
parent
643ec29645
commit
a63dae5d07
@ -1158,12 +1158,14 @@ static OSStatus CopyIdentityWithLabel(char *label,
|
||||
(SecIdentityRef) CFArrayGetValueAtIndex(keys_list, i);
|
||||
err = SecIdentityCopyCertificate(identity, &cert);
|
||||
if(err == noErr) {
|
||||
OSStatus copy_status = noErr;
|
||||
#if CURL_BUILD_IOS
|
||||
common_name = SecCertificateCopySubjectSummary(cert);
|
||||
#elif CURL_BUILD_MAC_10_7
|
||||
SecCertificateCopyCommonName(cert, &common_name);
|
||||
copy_status = SecCertificateCopyCommonName(cert, &common_name);
|
||||
#endif
|
||||
if(CFStringCompare(common_name, label_cf, 0) == kCFCompareEqualTo) {
|
||||
if(copy_status == noErr &&
|
||||
CFStringCompare(common_name, label_cf, 0) == kCFCompareEqualTo) {
|
||||
CFRelease(cert);
|
||||
CFRelease(common_name);
|
||||
CFRetain(identity);
|
||||
|
Loading…
Reference in New Issue
Block a user