diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2017-01-02 14:55:14 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2017-01-02 15:16:13 +0100 |
commit | cb7b004bd07a0579a5aa65f74642cb800112ad71 (patch) | |
tree | 4d1db045c6eccaa3341701de27de9e9cda2f0148 /src | |
parent | 222d588b1359da8a8161082a8225e6e5e1ae2655 (diff) | |
download | gnutls-cb7b004bd07a0579a5aa65f74642cb800112ad71.tar.gz |
certtool: pkcs8_info_int: fix memory leak
Diffstat (limited to 'src')
-rw-r--r-- | src/certtool.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/certtool.c b/src/certtool.c index 8fcf37a535..e3b850165d 100644 --- a/src/certtool.c +++ b/src/certtool.c @@ -3573,12 +3573,11 @@ void pkcs8_info_int(gnutls_datum_t *data, unsigned format, if (ret == GNUTLS_E_UNKNOWN_CIPHER_TYPE) { fprintf(out, "PKCS #8 information:\n"); fprintf(out, "\tSchema: unsupported (%s)\n", oid); - gnutls_free(oid); - return; + goto cleanup; } else if (ret == GNUTLS_E_INVALID_REQUEST) { fprintf(out, "PKCS #8 information:\n"); fprintf(out, "\tSchema: unencrypted key\n"); - return; + goto cleanup; } if (ret < 0) { @@ -3588,16 +3587,16 @@ void pkcs8_info_int(gnutls_datum_t *data, unsigned format, gnutls_strerror(ret)); exit(1); } - gnutls_free(oid); fprintf(out, "%sPKCS #8 information:\n", tab); fprintf(out, "%s\tCipher: %s\n", tab, gnutls_cipher_get_name(cipher)); str = gnutls_pkcs_schema_get_name(schema); if (str != NULL) { - fprintf(out, "%s\tSchema: %s (%s)\n", tab, str, gnutls_pkcs_schema_get_oid(schema)); + fprintf(out, "%s\tSchema: %s (%s)\n", tab, str, gnutls_pkcs_schema_get_oid(schema)); } + bin.data = salt; bin.size = salt_size; ret = gnutls_hex_encode(&bin, hex, &hex_size); @@ -3610,6 +3609,9 @@ void pkcs8_info_int(gnutls_datum_t *data, unsigned format, fprintf(out, "%s\tSalt: %s\n", tab, hex); fprintf(out, "%s\tSalt size: %u\n", tab, salt_size); fprintf(out, "%s\tIteration count: %u\n\n", tab, iter_count); + + cleanup: + gnutls_free(oid); } void pkcs8_info(void) |