File libgcrypt-bsc932232-avoid-drbg-crash-with-fips.patch of Package libgcrypt.1570

diff --git a/random/drbg.c b/random/drbg.c
index f2cf078..ea011ea 100644
--- a/random/drbg.c
+++ b/random/drbg.c
@@ -1709,6 +1709,20 @@ _gcry_drbg_init (int full)
   gcry_drbg_unlock ();
 }
 
+/* Called after the initial FIPS self-tests. This is necessary in order
+ * to avoid a crash later if the client code changes the allocation handlers
+ * before completing initialization. */
+void
+_gcry_drbg_uninit (void)
+{
+  gcry_drbg_lock ();
+  if (NULL != gcry_drbg)
+    {
+      gcry_drbg_uninstantiate (gcry_drbg);
+    }
+  gcry_drbg_unlock ();
+}
+
 /*
  * Backend handler function for GCRYCTL_DRBG_REINIT
  *
diff --git a/random/rand-internal.h b/random/rand-internal.h
index 475351a..6c48137 100644
--- a/random/rand-internal.h
+++ b/random/rand-internal.h
@@ -90,6 +90,7 @@ void _gcry_rngfips_deinit_external_test (void *context);
 
 /* drbg-gcry.h */
 void _gcry_drbg_init(int full);
+void _gcry_drbg_uninit (void);
 void _gcry_drbg_close_fds(void);
 void _gcry_drbg_dump_stats(void);
 int _gcry_drbg_is_faked (void);
diff --git a/src/global.c b/src/global.c
index ea11923..fbac8aa 100644
--- a/src/global.c
+++ b/src/global.c
@@ -131,6 +131,11 @@ global_init (void)
   if (err)
     goto fail;
 
+  /* This is necessary in order to avoid a crash later if the client
+   * code changes the allocation handlers before completing
+   * initialization. */
+  _gcry_drbg_uninit ();
+
   return;
 
  fail:
openSUSE Build Service is sponsored by