libgit2/0003-openssl-use-ASN1_STRING_get0_data-when-compiling-aga.patch
2017-01-10 14:43:43 +01:00

56 lines
1.8 KiB
Diff

From c16736c6b5c13350df4c41f76b1815e6bbe6ee0a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= <cmn@dwim.me>
Date: Wed, 2 Nov 2016 12:35:46 +0100
Subject: [PATCH 3/4] openssl: use ASN1_STRING_get0_data when compiling against
1.1
For older versions we can fall back on the deprecated ASN1_STRING_data.
(cherry picked from commit 2f3adf9513b1579ae17489d45d032b962bba885a)
---
src/openssl_stream.c | 4 ++--
src/openssl_stream.h | 5 +++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/openssl_stream.c b/src/openssl_stream.c
index 328a131..64187a8 100644
--- a/src/openssl_stream.c
+++ b/src/openssl_stream.c
@@ -357,7 +357,7 @@ static int verify_server_cert(SSL *ssl, const char *host)
num = sk_GENERAL_NAME_num(alts);
for (i = 0; i < num && matched != 1; i++) {
const GENERAL_NAME *gn = sk_GENERAL_NAME_value(alts, i);
- const char *name = (char *) ASN1_STRING_data(gn->d.ia5);
+ const char *name = (char *) ASN1_STRING_get0_data(gn->d.ia5);
size_t namelen = (size_t) ASN1_STRING_length(gn->d.ia5);
/* 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)
if (size > 0) {
peer_cn = OPENSSL_malloc(size + 1);
GITERR_CHECK_ALLOC(peer_cn);
- memcpy(peer_cn, ASN1_STRING_data(str), size);
+ memcpy(peer_cn, ASN1_STRING_get0_data(str), size);
peer_cn[size] = '\0';
} else {
goto cert_fail_name;
diff --git a/src/openssl_stream.h b/src/openssl_stream.h
index 509e404..e8ce5d9 100644
--- a/src/openssl_stream.h
+++ b/src/openssl_stream.h
@@ -108,6 +108,11 @@ GIT_INLINE(void*) BIO_get_data(BIO *a)
return a->ptr;
}
+GIT_INLINE(const unsigned char *) ASN1_STRING_get0_data(const ASN1_STRING *x)
+{
+ return ASN1_STRING_data((ASN1_STRING *)x);
+}
+
# endif
#endif
--
2.10.1