Skip to content

Commit 9884dd6

Browse files
committed
SecureTransport: handle NULL trust on success
The `SSLCopyPeerTrust` call can succeed but fail to return a trust object if it can't load the certificate chain and thus cannot check the validity of a certificate. This can lead to us calling `CFRelease` on a `NULL` trust object, causing a crash. Handle this by returning ECERTIFICATE.
1 parent cba60b9 commit 9884dd6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/stransport_stream.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ int stransport_connect(git_stream *stream)
6767
if ((ret = SSLCopyPeerTrust(st->ctx, &trust)) != noErr)
6868
goto on_error;
6969

70+
if (!trust)
71+
return GIT_ECERTIFICATE;
72+
7073
if ((ret = SecTrustEvaluate(trust, &sec_res)) != noErr)
7174
goto on_error;
7275

0 commit comments

Comments
 (0)