]> granicus.if.org Git - openssl/commitdiff
Fix memory leak.
authorDr. Stephen Henson <steve@openssl.org>
Tue, 3 Jul 2012 16:37:31 +0000 (16:37 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Tue, 3 Jul 2012 16:37:31 +0000 (16:37 +0000)
Always perform nexproto callback argument initialisation in s_server
otherwise we use uninitialised data if -nocert is specified.

apps/s_client.c
apps/s_server.c

index 2b2b740778890d70134ac4b00141c46a251e0e2e..e64aaf66c681d67a502c2d1e43a856ffcf1a83d5 100644 (file)
@@ -1910,6 +1910,10 @@ end:
                        print_stuff(bio_c_out,con,1);
                SSL_free(con);
                }
+#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
+       if (next_proto.data)
+               OPENSSL_free(next_proto.data);
+#endif
        if (ctx != NULL) SSL_CTX_free(ctx);
        if (cert)
                X509_free(cert);
index cfe9a34c37de633f00a466dcb5092a31ec96d024..9692c70b2de5c4900d21dbc3633628279695eeb5 100644 (file)
@@ -1470,25 +1470,24 @@ bad:
                                goto end;
                                }
                        }
-
-# ifndef OPENSSL_NO_NEXTPROTONEG
-               if (next_proto_neg_in)
-                       {
-                       unsigned short len;
-                       next_proto.data = next_protos_parse(&len,
-                               next_proto_neg_in);
-                       if (next_proto.data == NULL)
-                               goto end;
-                       next_proto.len = len;
-                       }
-               else
-                       {
-                       next_proto.data = NULL;
-                       }
-# endif
 #endif /* OPENSSL_NO_TLSEXT */
                }
 
+#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) 
+       if (next_proto_neg_in)
+               {
+               unsigned short len;
+               next_proto.data = next_protos_parse(&len, next_proto_neg_in);
+               if (next_proto.data == NULL)
+                       goto end;
+               next_proto.len = len;
+               }
+       else
+               {
+               next_proto.data = NULL;
+               }
+#endif
+
 
        if (s_dcert_file)
                {