From d00fd03ec716c70821fee1723de4f22b26b7a99a Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Fri, 31 Mar 2017 16:17:07 +0200 Subject: gnutls_pkcs8_info: do not free oid on GNUTLS_E_UNKNOWN_CIPHER_TYPE The documented behavior of the function was to return a valid OID in that case. Signed-off-by: Nikos Mavrogiannopoulos --- lib/x509/privkey_pkcs8.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/x509/privkey_pkcs8.c b/lib/x509/privkey_pkcs8.c index 8186ececcb..87eafca637 100644 --- a/lib/x509/privkey_pkcs8.c +++ b/lib/x509/privkey_pkcs8.c @@ -458,6 +458,8 @@ gnutls_x509_privkey_export_pkcs8(gnutls_x509_privkey_t key, * Returns: %GNUTLS_E_INVALID_REQUEST if the provided structure isn't an encrypted key, * %GNUTLS_E_UNKNOWN_CIPHER_TYPE if the structure's encryption isn't supported, or * another negative error code in case of a failure. Zero on success. + * + * Since: 3.4.0 **/ int gnutls_pkcs8_info(const gnutls_datum_t * data, gnutls_x509_crt_fmt_t format, @@ -537,8 +539,10 @@ gnutls_pkcs8_info(const gnutls_datum_t * data, gnutls_x509_crt_fmt_t format, return 0; cleanup: - if (oid) + if (ret != GNUTLS_E_UNKNOWN_CIPHER_TYPE && oid) { gnutls_free(*oid); + *oid = NULL; + } if (need_free) _gnutls_free_datum(&_data); return ret; -- cgit v1.2.1