aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo@golang.org>2019-05-21 14:54:54 -0400
committerDmitri Shuralyov <dmitshur@golang.org>2019-06-07 20:51:11 +0000
commit3b05c3c2e68296ebcb9efd9b4b0739161dac964f (patch)
tree37d6867e13b20d9113ab93900be39f59f9f4f85a
parentafcfe0d3c2980722af0dc55a3422c19cc53f5a65 (diff)
downloadgo-3b05c3c2e68296ebcb9efd9b4b0739161dac964f.tar.gz
go-3b05c3c2e68296ebcb9efd9b4b0739161dac964f.zip
[release-branch.go1.12] crypto/x509: fix value ownership in isSSLPolicy on macOS
CFDictionaryGetValueIfPresent does not take ownership of the value, so releasing the properties dictionary before passing the value to CFEqual can crash. Not really clear why this works most of the time. See https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html Fixes #32282 Updates #28092 Updates #30763 Change-Id: I5ee7ca276b753a48abc3aedfb78b8af68b448dd4 Reviewed-on: https://go-review.googlesource.com/c/go/+/178537 Reviewed-by: Adam Langley <agl@golang.org> (cherry picked from commit a3d4655c2435e3777c45f09650539b943bab1c66) Reviewed-on: https://go-review.googlesource.com/c/go/+/179339 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
-rw-r--r--src/crypto/x509/root_cgo_darwin.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/crypto/x509/root_cgo_darwin.go b/src/crypto/x509/root_cgo_darwin.go
index e6332072d6..1c20f26acb 100644
--- a/src/crypto/x509/root_cgo_darwin.go
+++ b/src/crypto/x509/root_cgo_darwin.go
@@ -16,7 +16,7 @@ package x509
#include <CoreFoundation/CoreFoundation.h>
#include <Security/Security.h>
-static bool isSSLPolicy(SecPolicyRef policyRef) {
+static Boolean isSSLPolicy(SecPolicyRef policyRef) {
if (!policyRef) {
return false;
}
@@ -24,13 +24,13 @@ static bool isSSLPolicy(SecPolicyRef policyRef) {
if (properties == NULL) {
return false;
}
+ Boolean isSSL = false;
CFTypeRef value = NULL;
if (CFDictionaryGetValueIfPresent(properties, kSecPolicyOid, (const void **)&value)) {
- CFRelease(properties);
- return CFEqual(value, kSecPolicyAppleSSL);
+ isSSL = CFEqual(value, kSecPolicyAppleSSL);
}
CFRelease(properties);
- return false;
+ return isSSL;
}
// sslTrustSettingsResult obtains the final kSecTrustSettingsResult value