]> granicus.if.org Git - curl/commitdiff
openssl: engine: remove double-free
authorDaniel Stenberg <daniel@haxx.se>
Tue, 27 Oct 2015 12:45:25 +0000 (13:45 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 27 Oct 2015 12:45:25 +0000 (13:45 +0100)
After a successful call to SSL_CTX_use_PrivateKey(), we must not call
EVP_PKEY_free() on the key.

Reported-by: nased0
Closes #509

lib/vtls/openssl.c

index 3bc079e7ebdd5be3fa7ea491f78364dc7337e70c..f93a89507a5cc093f7cd99e5ae6b8d1ee494fdfb 100644 (file)
@@ -558,7 +558,7 @@ int cert_stuff(struct connectdata *conn,
       break;
     case SSL_FILETYPE_ENGINE:
 #ifdef HAVE_OPENSSL_ENGINE_H
-      {                         /* XXXX still needs some work */
+      {
         EVP_PKEY *priv_key = NULL;
         if(data->state.engine) {
 #ifdef HAVE_ENGINE_LOAD_FOUR_ARGS
@@ -592,7 +592,7 @@ int cert_stuff(struct connectdata *conn,
             EVP_PKEY_free(priv_key);
             return 0;
           }
-          EVP_PKEY_free(priv_key);  /* we don't need the handle any more... */
+          /* ownership of priv_key was handed over, no need to free it here */
         }
         else {
           failf(data, "crypto engine not set, can't load private key");