From: Seonah Moon Date: Tue, 4 Oct 2016 07:35:59 +0000 (+0900) Subject: openssl: fix bad memory free (regression) X-Git-Tag: accepted/tizen/3.0/ivi/20161011.043815^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fcurl.git;a=commitdiff_plain;h=5842f4e35c2d3c9df52301359e2888850f988c9d openssl: fix bad memory free (regression) The allocation could be made by OpenSSL so the free must be made with OPENSSL_free() to avoid problems. (https://github.com/curl/curl/issues/1005) Change-Id: I07527924fe20ed859cbd5d7ade356410c64d71c7 Signed-off-by: Seonah Moon --- diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index 0a3e6a3..0a46f9d 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;