summaryrefslogtreecommitdiff
path: root/src/lib/dev.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2019-07-26 12:07:21 +0200
committerSander Vrijders <sander@ouroboros.rocks>2019-07-29 19:58:20 +0200
commit8a37ffbf8c0776a38f2de18a63e885383960ee68 (patch)
tree1f8c7fc954f47b561281a23b4510546f3e501f99 /src/lib/dev.c
parentdae15c284248d49079ad5f8a3d8ff30e217f419e (diff)
downloadouroboros-8a37ffbf8c0776a38f2de18a63e885383960ee68.tar.gz
ouroboros-8a37ffbf8c0776a38f2de18a63e885383960ee68.zip
irmd, lib: Improve libgcrypt init
The proper initialization of libgrypt requires a call to gcry_check_version. The library initialization should first run a check if the application (or some other library) hasn't already initialized libgcrypt before attempting to initialize libgcrypt. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/lib/dev.c')
-rw-r--r--src/lib/dev.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index ee7839c8..229a1470 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -344,8 +344,13 @@ static void init(int argc,
ai.pid = getpid();
#ifdef HAVE_LIBGCRYPT
- if (!gcry_check_version(GCRYPT_VERSION))
- goto fail_fds;
+ if (!gcry_control (GCRYCTL_INITIALIZATION_FINISHED_P)) {
+ if (!gcry_check_version(GCRYPT_VERSION))
+ goto fail_fds;
+ /* Needs to be enabled when we add encryption. */
+ gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
+ gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
+ }
#endif
ai.fds = bmp_create(PROG_MAX_FLOWS - PROG_RES_FDS, PROG_RES_FDS);
if (ai.fds == NULL)