aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2016-09-09 23:33:09 +0200
committerDaniel Stenberg <daniel@haxx.se>2016-09-09 23:35:10 +0200
commit83ef21e5e9946de2805ae10cc5e6ef9431b22702 (patch)
treea6e02f077e8c0edb46db0f8b5bd2a505510ef316 /lib
parent85033bcfccc826047bc4f847ecc0c21c2a9415fe (diff)
openssl: fix bad memory free (regression)
... by partially reverting f975f06033b1. The allocation could be made by OpenSSL so the free must be made with OPENSSL_free() to avoid problems. Reported-by: Harold Stuart Fixes #1005
Diffstat (limited to 'lib')
-rw-r--r--lib/vtls/openssl.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
index 0a3e6a3be..0a46f9d43 100644
--- a/lib/vtls/openssl.c
+++ b/lib/vtls/openssl.c
@@ -1223,7 +1223,7 @@ static CURLcode verifyhost(struct connectdata *conn, X509 *server_cert)
if(ASN1_STRING_type(tmp) == V_ASN1_UTF8STRING) {
j = ASN1_STRING_length(tmp);
if(j >= 0) {
- peer_CN = malloc(j+1);
+ peer_CN = OPENSSL_malloc(j+1);
if(peer_CN) {
memcpy(peer_CN, ASN1_STRING_get0_data(tmp), j);
peer_CN[j] = '\0';
@@ -1249,7 +1249,7 @@ static CURLcode verifyhost(struct connectdata *conn, X509 *server_cert)
CURLcode rc = Curl_convert_from_utf8(data, peer_CN, strlen(peer_CN));
/* Curl_convert_from_utf8 calls failf if unsuccessful */
if(rc) {
- free(peer_CN);
+ OPENSSL_free(peer_CN);
return rc;
}
}
@@ -1271,7 +1271,7 @@ static CURLcode verifyhost(struct connectdata *conn, X509 *server_cert)
infof(data, " common name: %s (matched)\n", peer_CN);
}
if(peer_CN)
- free(peer_CN);
+ OPENSSL_free(peer_CN);
}
return result;