diff options
author | Alexander Couzens <lynxis@fe80.eu> | 2018-04-24 14:00:24 +0200 |
---|---|---|
committer | Alexander Couzens <lynxis@fe80.eu> | 2018-05-02 15:45:56 +0200 |
commit | 500d633762e28613077a61d6c8dcc7d260f4a984 (patch) | |
tree | 3bdf4eb2371555d4ad08c4c1ed56d9dfb5597b37 /src/gsm | |
parent | 178bf7a409209d3bb39727ac92c8ce60ee23c283 (diff) |
gsm_utils: call gnutls_global_init() as constructor
gnutls_global_init must be called at least once for
gnutls < 3.3.0. It doesn't hurt calling it twice, except
a reference counter is increased.
gnutls >= 3.3.0 will call it automatic.
Fixes: OS#2986
Change-Id: I241b6ae5aa8df13dd78f04658cf0953e9561c9e2
Diffstat (limited to 'src/gsm')
-rw-r--r-- | src/gsm/gsm_utils.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c index 5d8c834e..7e6c7947 100644 --- a/src/gsm/gsm_utils.c +++ b/src/gsm/gsm_utils.c @@ -112,6 +112,25 @@ #pragma message ("including GnuTLS for getrandom fallback.") #include <gnutls/gnutls.h> #include <gnutls/crypto.h> + +/* gnutls < 3.3.0 requires global init. + * gnutls >= 3.3.0 does it automatic. + * It doesn't hurt calling it twice, + * as long it's not done at the same time (threads). + */ +__attribute__((constructor)) +static void on_dso_load_gnutls(void) +{ + if (!gnutls_check_version("3.3.0")) + gnutls_global_init(); +} + +__attribute__((destructor)) +static void on_dso_unload_gnutls(void) +{ + if (!gnutls_check_version("3.3.0")) + gnutls_global_deinit(); +} #endif /* ETSI GSM 03.38 6.2.1 and 6.2.1.1 default alphabet |