Skip to content
Snippets Groups Projects
Commit 9800f8df authored by Tristan Matthews's avatar Tristan Matthews Committed by Alexandre Lision
Browse files

tls: fix broken error handling

We shouldn't call gnu_tls_global_deinit() if gnu_tls_global_init()
hasn't been called, and we especially shouldn't call
gnutls_x509_privkey_deinit on an uninitialized key.

Refs #51340

Change-Id: I0d4a9dd3814e76f78d511d9fa5447308d6733291
parent bb5069dd
No related branches found
No related tags found
No related merge requests found
......@@ -293,13 +293,16 @@ int containsPrivateKey(const char *pemPath)
err = gnutls_global_init();
if (err != GNUTLS_E_SUCCESS) {
ERROR("Could not init GnuTLS - %s", gnutls_strerror(err));
goto out;
free(dt.data);
return res;
}
err = gnutls_x509_privkey_init(&key);
if (err != GNUTLS_E_SUCCESS) {
ERROR("Could not init key - %s", gnutls_strerror(err));
goto out;
free(dt.data);
gnutls_global_deinit();
return res;
}
err = gnutls_x509_privkey_import(key, &dt, GNUTLS_X509_FMT_PEM);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment