From: Nikos Mavrogiannopoulos Date: Thu, 19 Mar 2015 20:12:27 +0000 (+0100) Subject: deinitialize supplemental data on deinit X-Git-Tag: gnutls_3_4_0~158 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ca2c06db1bfa8ed0c07c91669591949fd67a4bfd;p=thirdparty%2Fgnutls.git deinitialize supplemental data on deinit --- diff --git a/lib/gnutls_global.c b/lib/gnutls_global.c index cb7448af64..d4a98537da 100644 --- a/lib/gnutls_global.c +++ b/lib/gnutls_global.c @@ -389,6 +389,8 @@ static void _gnutls_global_deinit(unsigned destructor) gnutls_system_global_deinit(); _gnutls_cryptodev_deinit(); + _gnutls_supplemental_deinit(); + #ifdef ENABLE_PKCS11 /* Do not try to deinitialize the PKCS #11 libraries * from the destructor. If we do and the PKCS #11 modules diff --git a/lib/gnutls_supplemental.c b/lib/gnutls_supplemental.c index d307f2097d..e7c4c42ff0 100644 --- a/lib/gnutls_supplemental.c +++ b/lib/gnutls_supplemental.c @@ -50,7 +50,7 @@ #include "gnutls_num.h" typedef struct { - const char *name; + char *name; gnutls_supplemental_data_format_type_t type; supp_recv_func supp_recv_func; supp_send_func supp_send_func; @@ -83,6 +83,19 @@ const char return NULL; } +void _gnutls_supplemental_deinit(void) +{ + unsigned i; + + for (i = 0; i < suppfunc_size; i++) { + gnutls_free(suppfunc[i].name); + } + gnutls_free(suppfunc); + + suppfunc = NULL; + suppfunc_size = 0; +} + static supp_recv_func get_supp_func_recv(gnutls_supplemental_data_format_type_t type) { @@ -234,6 +247,8 @@ _gnutls_supplemental_register(gnutls_supplemental_entry *entry) * @send_func: the function to send the data * * This function will register a new supplemental data type (rfc4680). + * The registered data will remain until gnutls_global_deinit() + * is called. * * Returns: %GNUTLS_E_SUCCESS on success, otherwise a negative error code. * @@ -245,7 +260,7 @@ gnutls_supplemental_register(const char *name, gnutls_supplemental_data_format_t { gnutls_supplemental_entry tmp_entry; - tmp_entry.name = name; + tmp_entry.name = strdup(name); tmp_entry.type = type; tmp_entry.supp_recv_func = recv_func; tmp_entry.supp_send_func = send_func; diff --git a/lib/gnutls_supplemental.h b/lib/gnutls_supplemental.h index 03c3f3b5f7..63004f57ad 100644 --- a/lib/gnutls_supplemental.h +++ b/lib/gnutls_supplemental.h @@ -26,3 +26,5 @@ int _gnutls_parse_supplemental(gnutls_session_t session, const uint8_t * data, int data_size); int _gnutls_gen_supplemental(gnutls_session_t session, gnutls_buffer_st * buf); + +void _gnutls_supplemental_deinit(void);