From 80d8e6744a2736e25ac2d991b51ac2a6710b0994 Mon Sep 17 00:00:00 2001 From: Chris Lundquist Date: Fri, 12 Oct 2012 03:15:13 -0700 Subject: [PATCH] network.c: call gcry_check_version() as required by library. Signed-off-by: Florian Forster --- src/network.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/network.c b/src/network.c index 570b9d4f..d6e0dc01 100644 --- a/src/network.c +++ b/src/network.c @@ -3348,9 +3348,17 @@ static int network_init (void) have_init = true; #if HAVE_LIBGCRYPT - gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); - gcry_control (GCRYCTL_INIT_SECMEM, 32768, 0); - gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); + /* http://lists.gnupg.org/pipermail/gcrypt-devel/2003-August/000458.html + * Because you can't know in a library whether another library has + * already initialized the library + */ + if (!gcry_control (GCRYCTL_ANY_INITIALIZATION_P)) + { + gcry_check_version(NULL); /* before calling any other functions */ + gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); + gcry_control (GCRYCTL_INIT_SECMEM, 32768, 0); + gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); + } #endif if (network_config_stats != 0) -- 2.30.2