sectransp: fix compiler warning c89 mixed code/declaration

Since cbf57176 the Cirrus CI 'macOS arm64 SecureTransport http2' has
been failing due to c89 warnings mixed code/declaration. That commit is
not the cause so I assume something has changed in the CI outside of our
configuration. Anyway, we don't mix code/declaration so this is the fix
for that.

Closes https://github.com/curl/curl/pull/10574
This commit is contained in:
Jay Satiro 2023-02-20 23:28:14 -05:00
parent c52f7a8946
commit 47129b2b4b

View File

@ -2202,16 +2202,18 @@ static int append_cert_to_array(struct Curl_easy *data,
const unsigned char *buf, size_t buflen, const unsigned char *buf, size_t buflen,
CFMutableArrayRef array) CFMutableArrayRef array)
{ {
CFDataRef certdata = CFDataCreate(kCFAllocatorDefault, buf, buflen);
char *certp; char *certp;
CURLcode result; CURLcode result;
SecCertificateRef cacert;
CFDataRef certdata;
certdata = CFDataCreate(kCFAllocatorDefault, buf, buflen);
if(!certdata) { if(!certdata) {
failf(data, "SSL: failed to allocate array for CA certificate"); failf(data, "SSL: failed to allocate array for CA certificate");
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
} }
SecCertificateRef cacert = cacert = SecCertificateCreateWithData(kCFAllocatorDefault, certdata);
SecCertificateCreateWithData(kCFAllocatorDefault, certdata);
CFRelease(certdata); CFRelease(certdata);
if(!cacert) { if(!cacert) {
failf(data, "SSL: failed to create SecCertificate from CA certificate"); failf(data, "SSL: failed to create SecCertificate from CA certificate");
@ -2425,11 +2427,15 @@ static CURLcode pkp_pin_peer_pubkey(struct Curl_easy *data,
do { do {
SecTrustRef trust; SecTrustRef trust;
OSStatus ret = SSLCopyPeerTrust(ctx, &trust); OSStatus ret;
SecKeyRef keyRef;
OSStatus success;
ret = SSLCopyPeerTrust(ctx, &trust);
if(ret != noErr || !trust) if(ret != noErr || !trust)
break; break;
SecKeyRef keyRef = SecTrustCopyPublicKey(trust); keyRef = SecTrustCopyPublicKey(trust);
CFRelease(trust); CFRelease(trust);
if(!keyRef) if(!keyRef)
break; break;
@ -2443,7 +2449,7 @@ static CURLcode pkp_pin_peer_pubkey(struct Curl_easy *data,
#elif SECTRANSP_PINNEDPUBKEY_V2 #elif SECTRANSP_PINNEDPUBKEY_V2
OSStatus success = SecItemExport(keyRef, kSecFormatOpenSSL, 0, NULL, success = SecItemExport(keyRef, kSecFormatOpenSSL, 0, NULL,
&publicKeyBits); &publicKeyBits);
CFRelease(keyRef); CFRelease(keyRef);
if(success != errSecSuccess || !publicKeyBits) if(success != errSecSuccess || !publicKeyBits)
@ -2987,12 +2993,13 @@ static CURLcode sectransp_connect_step3(struct Curl_cfilter *cf,
struct Curl_easy *data) struct Curl_easy *data)
{ {
struct ssl_connect_data *connssl = cf->ctx; struct ssl_connect_data *connssl = cf->ctx;
CURLcode result;
DEBUGF(LOG_CF(data, cf, "connect_step3")); DEBUGF(LOG_CF(data, cf, "connect_step3"));
/* There is no step 3! /* There is no step 3!
* Well, okay, let's collect server certificates, and if verbose mode is on, * Well, okay, let's collect server certificates, and if verbose mode is on,
* let's print the details of the server certificates. */ * let's print the details of the server certificates. */
const CURLcode result = collect_server_cert(cf, data); result = collect_server_cert(cf, data);
if(result) if(result)
return result; return result;