Skip to content

Commit

Permalink
Fix memory leak.
Browse files Browse the repository at this point in the history
Always perform nexproto callback argument initialisation in s_server
otherwise we use uninitialised data if -nocert is specified.
  • Loading branch information
snhenson committed Jul 3, 2012
1 parent 657e29c commit dd25165
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
4 changes: 4 additions & 0 deletions apps/s_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,10 @@ printf("read=%d pending=%d peek=%d\n",k,SSL_pending(con),SSL_peek(con,zbuf,10240
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);
Expand Down
31 changes: 15 additions & 16 deletions apps/s_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1518,25 +1518,24 @@ int MAIN(int argc, char *argv[])
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)
{
Expand Down

0 comments on commit dd25165

Please sign in to comment.