]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Avoid memory leak in safe renegotiation extension handling.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 8 May 2014 17:46:51 +0000 (19:46 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 8 May 2014 17:46:51 +0000 (19:46 +0200)
The memory leak was uncovered by the Codenomicon TLS suite.

lib/ext/safe_renegotiation.c

index 8975641417a670b8b3a9f0fb2c4e27144a050776..314c4e2749f6a0b364f4146711d5f7754ef555b1 100644 (file)
@@ -294,8 +294,13 @@ _gnutls_sr_recv_params(gnutls_session_t session,
                        return GNUTLS_E_MEMORY_ERROR;
                }
                epriv.ptr = priv;
-       } else
+
+               _gnutls_ext_set_session_data(session,
+                                            GNUTLS_EXTENSION_SAFE_RENEGOTIATION,
+                                            epriv);
+       } else {
                priv = epriv.ptr;
+       }
 
        /* It is not legal to receive this extension on a renegotiation and
         * not receive it on the initial negotiation.
@@ -322,10 +327,6 @@ _gnutls_sr_recv_params(gnutls_session_t session,
        priv->safe_renegotiation_received = 1;
        priv->connection_using_safe_renegotiation = 1;
 
-       if (set != 0)
-               _gnutls_ext_set_session_data(session,
-                                            GNUTLS_EXTENSION_SAFE_RENEGOTIATION,
-                                            epriv);
        return 0;
 }