Skip to content

Commit c631017

Browse files
committed
Fix leak in get_peer_cert_info
Summary: Valgrind shows that we are not freeing the X509 object that is returned when we call SSL_get_peer_certificate. Fix this by free'ing it at various exit points. Squash with: f29eb03 Expose user certificate details to command line. Test Plan: mysqltest.sh --valgrind main.information_schema_authinfo Reviewers: kradhakrishnan Reviewed By: kradhakrishnan Subscribers: jkedgar, webscalesql-eng Differential Revision: https://reviews.facebook.net/D53169
1 parent 4f8d6fb commit c631017

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sql/sql_show.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,13 +2149,15 @@ BUF_MEM *get_peer_cert_info(THD *thd)
21492149
// Create new X509 buffer abstraction
21502150
BIO *bio = BIO_new(BIO_s_mem());
21512151
if (!bio) {
2152+
X509_free(cert);
21522153
return NULL;
21532154
}
21542155

21552156
// Print the certificate to the buffer
21562157
int status = X509_print(bio, cert);
21572158
if (status != 1) {
21582159
BIO_free(bio);
2160+
X509_free(cert);
21592161
return NULL;
21602162
}
21612163

@@ -2164,6 +2166,7 @@ BUF_MEM *get_peer_cert_info(THD *thd)
21642166
BIO_get_mem_ptr(bio, &bufmem);
21652167
(void) BIO_set_close(bio, BIO_NOCLOSE);
21662168
BIO_free(bio);
2169+
X509_free(cert);
21672170

21682171
assert(bufmem->length <= bufmem->max);
21692172
if (bufmem->length) {

0 commit comments

Comments
 (0)