Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2fd1dea

Browse files
committed
openssl: use ASN1_STRING_get0_data when compiling against 1.1
For older versions we can fall back on the deprecated ASN1_STRING_data.
1 parent f15eedb commit 2fd1dea

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/openssl_stream.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ static int verify_server_cert(SSL *ssl, const char *host)
357357
num = sk_GENERAL_NAME_num(alts);
358358
for (i = 0; i < num && matched != 1; i++) {
359359
const GENERAL_NAME *gn = sk_GENERAL_NAME_value(alts, i);
360-
const char *name = (char *) ASN1_STRING_data(gn->d.ia5);
360+
const char *name = (char *) ASN1_STRING_get0_data(gn->d.ia5);
361361
size_t namelen = (size_t) ASN1_STRING_length(gn->d.ia5);
362362

363363
/* Skip any names of a type we're not looking for */
@@ -412,7 +412,7 @@ static int verify_server_cert(SSL *ssl, const char *host)
412412
if (size > 0) {
413413
peer_cn = OPENSSL_malloc(size + 1);
414414
GITERR_CHECK_ALLOC(peer_cn);
415-
memcpy(peer_cn, ASN1_STRING_data(str), size);
415+
memcpy(peer_cn, ASN1_STRING_get0_data(str), size);
416416
peer_cn[size] = '\0';
417417
} else {
418418
goto cert_fail_name;

src/openssl_stream.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ GIT_INLINE(void*) BIO_get_data(BIO *a)
108108
return a->ptr;
109109
}
110110

111+
GIT_INLINE(const unsigned char *) ASN1_STRING_get0_data(const ASN1_STRING *x)
112+
{
113+
return ASN1_STRING_data(x);
114+
}
115+
111116
# endif
112117

113118
#endif

0 commit comments

Comments
 (0)