File libgcrypt-bsc932232-avoid-drbg-crash-with-fips.patch of Package libgcrypt.2239
diff --git a/random/drbg.c b/random/drbg.c
index f2cf078..c29d240 100644
--- a/random/drbg.c
+++ b/random/drbg.c
@@ -1709,6 +1709,19 @@ _gcry_drbg_init (int full)
gcry_drbg_unlock ();
}
+void
+_gcry_drbg_uninit (void)
+{
+ gcry_drbg_lock ();
+ if (NULL != gcry_drbg)
+ {
+ gcry_drbg_uninstantiate (gcry_drbg);
+ xfree (gcry_drbg);
+ gcry_drbg = NULL;
+ }
+ 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..1214174 100644
--- a/src/global.c
+++ b/src/global.c
@@ -740,11 +740,15 @@ _gcry_set_allocation_handler (gcry_handler_alloc_t new_alloc_func,
_gcry_inactivate_fips_mode ("custom allocation handler");
}
+ _gcry_drbg_uninit ();
+
alloc_func = new_alloc_func;
alloc_secure_func = new_alloc_secure_func;
is_secure_func = new_is_secure_func;
realloc_func = new_realloc_func;
free_func = new_free_func;
+
+ _gcry_drbg_init ();
}