1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-16 14:35:03 -05:00

darwinssl: aprintf() to allocate the session key

... to avoid using a fixed memory size that risks being too large or too
small.
This commit is contained in:
Daniel Stenberg 2014-12-14 17:34:02 +01:00
parent 212e3e26bc
commit b13923f0f7

View File

@ -1468,7 +1468,7 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn,
/* Check if there's a cached ID we can/should use here! */ /* Check if there's a cached ID we can/should use here! */
if(!Curl_ssl_getsessionid(conn, (void **)&ssl_sessionid, if(!Curl_ssl_getsessionid(conn, (void **)&ssl_sessionid,
&ssl_sessionid_len)) { &ssl_sessionid_len)) {
/* we got a session id, use it! */ /* we got a session id, use it! */
err = SSLSetPeerID(connssl->ssl_ctx, ssl_sessionid, ssl_sessionid_len); err = SSLSetPeerID(connssl->ssl_ctx, ssl_sessionid, ssl_sessionid_len);
if(err != noErr) { if(err != noErr) {
@ -1482,10 +1482,9 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn,
to starting the handshake. */ to starting the handshake. */
else { else {
CURLcode retcode; CURLcode retcode;
ssl_sessionid = aprintf(ssl_sessionid, "curl:%s:%hu",
ssl_sessionid = malloc(256*sizeof(char)); conn->host.name, conn->remote_port);
ssl_sessionid_len = snprintf(ssl_sessionid, 256, "curl:%s:%hu", ssl_sessionid_len = strlen(ssl_sessionid);
conn->host.name, conn->remote_port);
err = SSLSetPeerID(connssl->ssl_ctx, ssl_sessionid, ssl_sessionid_len); err = SSLSetPeerID(connssl->ssl_ctx, ssl_sessionid, ssl_sessionid_len);
if(err != noErr) { if(err != noErr) {
failf(data, "SSL: SSLSetPeerID() failed: OSStatus %d", err); failf(data, "SSL: SSLSetPeerID() failed: OSStatus %d", err);