[openssl-commits] [openssl] master update

Rich Salz rsalz at openssl.org
Sun Apr 26 02:56:03 UTC 2015


The branch master has been updated
       via  a194ee7b9aab3c8fae2d5b840ce1ae81de940b48 (commit)
      from  46aa6078675132bce25c1d06878ae0fcc5f7cd55 (commit)


- Log -----------------------------------------------------------------
commit a194ee7b9aab3c8fae2d5b840ce1ae81de940b48
Author: Rich Salz <rsalz at openssl.org>
Date:   Sat Apr 25 22:55:36 2015 -0400

    Free malloc data on encoding errors.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 apps/s_server.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/apps/s_server.c b/apps/s_server.c
index 88309a6..da725e7 100644
--- a/apps/s_server.c
+++ b/apps/s_server.c
@@ -3169,6 +3169,7 @@ static int add_session(SSL *ssl, SSL_SESSION *session)
     sess->derlen = i2d_SSL_SESSION(session, NULL);
     if (sess->derlen < 0) {
         BIO_printf(bio_err, "Error encoding session\n");
+        OPENSSL_free(sess);
         return 0;
     }
 
@@ -3176,10 +3177,8 @@ static int add_session(SSL *ssl, SSL_SESSION *session)
     sess->der = OPENSSL_malloc(sess->derlen);
     if (!sess->id || !sess->der) {
         BIO_printf(bio_err, "Out of memory adding to external cache\n");
-        if (sess->id)
-            OPENSSL_free(sess->id);
-        if (sess->der)
-            OPENSSL_free(sess->der);
+        OPENSSL_free(sess->id);
+        OPENSSL_free(sess->der);
         OPENSSL_free(sess);
         return 0;
     }
@@ -3187,7 +3186,10 @@ static int add_session(SSL *ssl, SSL_SESSION *session)
 
     /* Assume it still works. */
     if (i2d_SSL_SESSION(session, &p) != sess->derlen) {
-        BIO_printf(bio_err, "Error encoding session\n");
+        BIO_printf(bio_err, "Re-encoding session strangeness\n");
+        OPENSSL_free(sess->id);
+        OPENSSL_free(sess->der);
+        OPENSSL_free(sess);
         return 0;
     }
 


More information about the openssl-commits mailing list