Fix memory leak.
authorDr. Stephen Henson <steve@openssl.org>
Tue, 3 Jul 2012 16:36:10 +0000 (16:36 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Tue, 3 Jul 2012 16:36:10 +0000 (16:36 +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 95d23e8608d1d1be086fde1bb957f110309bb0a7..374998f3c97f50bbcb33359d9e7d912a69d54be9 100644 (file)
@@ -1890,6 +1890,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 7125afafc30cd5c4cb3c26f147303635546d4c48..f15cd209144f236953a5c855ba02380df5da300f 100644 (file)
@@ -1431,25 +1431,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
                }
 
+#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)
                {