aboutsummaryrefslogtreecommitdiff
path: root/lib/vtls
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2014-12-14 17:34:02 +0100
committerDaniel Stenberg <daniel@haxx.se>2014-12-14 17:34:02 +0100
commitb13923f0f7ad697792de96adbf51867122f3ee4f (patch)
tree30e1e7aa6c7dbf8ba8f3feb19ef90194ed33fa7c /lib/vtls
parent212e3e26bc711c4bd2e0a1c2bbc14b4e40506917 (diff)
darwinssl: aprintf() to allocate the session key
... to avoid using a fixed memory size that risks being too large or too small.
Diffstat (limited to 'lib/vtls')
-rw-r--r--lib/vtls/curl_darwinssl.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/vtls/curl_darwinssl.c b/lib/vtls/curl_darwinssl.c
index f0e196301..b798acb89 100644
--- a/lib/vtls/curl_darwinssl.c
+++ b/lib/vtls/curl_darwinssl.c
@@ -1468,7 +1468,7 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn,
/* Check if there's a cached ID we can/should use here! */
if(!Curl_ssl_getsessionid(conn, (void **)&ssl_sessionid,
- &ssl_sessionid_len)) {
+ &ssl_sessionid_len)) {
/* we got a session id, use it! */
err = SSLSetPeerID(connssl->ssl_ctx, ssl_sessionid, ssl_sessionid_len);
if(err != noErr) {
@@ -1482,10 +1482,9 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn,
to starting the handshake. */
else {
CURLcode retcode;
-
- ssl_sessionid = malloc(256*sizeof(char));
- ssl_sessionid_len = snprintf(ssl_sessionid, 256, "curl:%s:%hu",
- conn->host.name, conn->remote_port);
+ ssl_sessionid = aprintf(ssl_sessionid, "curl:%s:%hu",
+ conn->host.name, conn->remote_port);
+ ssl_sessionid_len = strlen(ssl_sessionid);
err = SSLSetPeerID(connssl->ssl_ctx, ssl_sessionid, ssl_sessionid_len);
if(err != noErr) {
failf(data, "SSL: SSLSetPeerID() failed: OSStatus %d", err);