mirror of
https://github.com/curl/curl.git
synced 2025-09-19 02:22:47 +03: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);
|
(SecIdentityRef) CFArrayGetValueAtIndex(keys_list, i);
|
||||||
err = SecIdentityCopyCertificate(identity, &cert);
|
err = SecIdentityCopyCertificate(identity, &cert);
|
||||||
if(err == noErr) {
|
if(err == noErr) {
|
||||||
|
OSStatus copy_status = noErr;
|
||||||
#if CURL_BUILD_IOS
|
#if CURL_BUILD_IOS
|
||||||
common_name = SecCertificateCopySubjectSummary(cert);
|
common_name = SecCertificateCopySubjectSummary(cert);
|
||||||
#elif CURL_BUILD_MAC_10_7
|
#elif CURL_BUILD_MAC_10_7
|
||||||
SecCertificateCopyCommonName(cert, &common_name);
|
copy_status = SecCertificateCopyCommonName(cert, &common_name);
|
||||||
#endif
|
#endif
|
||||||
if(CFStringCompare(common_name, label_cf, 0) == kCFCompareEqualTo) {
|
if(copy_status == noErr &&
|
||||||
|
CFStringCompare(common_name, label_cf, 0) == kCFCompareEqualTo) {
|
||||||
CFRelease(cert);
|
CFRelease(cert);
|
||||||
CFRelease(common_name);
|
CFRelease(common_name);
|
||||||
CFRetain(identity);
|
CFRetain(identity);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user