File openssl-1.1.1-fips-fix-memory-leaks.patch of Package openssl-1_1
xxxxxxxxxx
1
---
2
crypto/fips/fips.c | 8 ++++++++
3
crypto/fips/fips_drbg_rand.c | 6 ++++++
4
crypto/init.c | 4 ++++
5
include/crypto/fips.h | 1 +
6
include/openssl/fips_rand.h | 1 +
7
5 files changed, 20 insertions(+)
8
9
--- a/crypto/fips/fips.c
10
+++ b/crypto/fips/fips.c
11
12
return fips_lock != NULL && fips_owning_lock != NULL;
13
}
14
15
+void FIPS_owning_thread_lock_cleanup(void)
16
+{
17
+ CRYPTO_THREAD_lock_free(fips_lock);
18
+ fips_lock = NULL;
19
+ CRYPTO_THREAD_lock_free(fips_owning_lock);
20
+ fips_owning_lock = NULL;
21
+}
22
+
23
# define fips_w_lock() CRYPTO_THREAD_write_lock(fips_lock)
24
# define fips_w_unlock() CRYPTO_THREAD_unlock(fips_lock)
25
# define fips_r_lock() CRYPTO_THREAD_read_lock(fips_lock)
26
--- a/crypto/fips/fips_drbg_rand.c
27
+++ b/crypto/fips/fips_drbg_rand.c
28
29
return &ossl_dctx;
30
}
31
32
+void FIPS_drbg_lock_cleanup(void)
33
+{
34
+ CRYPTO_THREAD_lock_free(fips_rand_lock);
35
+ fips_rand_lock = NULL;
36
+}
37
+
38
static int fips_drbg_bytes(unsigned char *out, int count)
39
{
40
DRBG_CTX *dctx = &ossl_dctx;
41
--- a/crypto/init.c
42
+++ b/crypto/init.c
43
44
#include "internal/dso.h"
45
#include "crypto/store.h"
46
#include "openssl/fips.h"
47
+#include "openssl/fips_rand.h"
48
+#include "crypto/fips.h"
49
50
static int stopped = 0;
51
52
53
conf_modules_free_int();
54
#ifdef OPENSSL_FIPS
55
FIPS_entropy_cleanup();
56
+ FIPS_drbg_lock_cleanup();
57
+ FIPS_owning_thread_lock_cleanup();
58
#endif
59
#ifndef OPENSSL_NO_ENGINE
60
engine_cleanup_int();
61
--- a/include/crypto/fips.h
62
+++ b/include/crypto/fips.h
63
64
65
#ifdef OPENSSL_FIPS
66
67
+void FIPS_owning_thread_lock_cleanup(void);
68
int FIPS_module_mode_set(int onoff);
69
int FIPS_module_mode(void);
70
int FIPS_module_installed(void);
71
--- a/include/openssl/fips_rand.h
72
+++ b/include/openssl/fips_rand.h
73
74
75
DRBG_CTX *FIPS_get_default_drbg(void);
76
const RAND_METHOD *FIPS_drbg_method(void);
77
+ void FIPS_drbg_lock_cleanup(void);
78
79
int FIPS_rand_set_method(const RAND_METHOD *meth);
80
const RAND_METHOD *FIPS_rand_get_method(void);
81