ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/mports/trunk/security/gnutls/files/patch-lib-random.c
Revision: 24731
Committed: Wed Nov 28 14:12:29 2018 UTC (5 years, 4 months ago) by laffer1
Content type: text/plain
File size: 1590 byte(s)
Log Message:
update to 3.5.19

File Contents

# Content
1 --- lib/random.c.orig 2017-01-08 09:27:28 UTC
2 +++ lib/random.c
3 @@ -33,24 +33,24 @@ void *gnutls_rnd_ctx;
4 GNUTLS_STATIC_MUTEX(gnutls_rnd_init_mutex);
5
6 #ifdef HAVE_STDATOMIC_H
7 -static atomic_uint rnd_initialized = 0;
8 +static atomic_uint rnd_initialized = ATOMIC_VAR_INIT(0);
9
10 inline static int _gnutls_rnd_init(void)
11 {
12 - if (unlikely(!rnd_initialized)) {
13 + if (unlikely(!atomic_load(&rnd_initialized))) {
14 if (_gnutls_rnd_ops.init == NULL) {
15 - rnd_initialized = 1;
16 + atomic_store(&rnd_initialized, 1);
17 return 0;
18 }
19
20 GNUTLS_STATIC_MUTEX_LOCK(gnutls_rnd_init_mutex);
21 - if (!rnd_initialized) {
22 + if (!atomic_load(&rnd_initialized)) {
23 if (_gnutls_rnd_ops.init(&gnutls_rnd_ctx) < 0) {
24 gnutls_assert();
25 GNUTLS_STATIC_MUTEX_UNLOCK(gnutls_rnd_init_mutex);
26 return GNUTLS_E_RANDOM_FAILED;
27 }
28 - rnd_initialized = 1;
29 + atomic_store(&rnd_initialized, 1);
30 }
31 GNUTLS_STATIC_MUTEX_UNLOCK(gnutls_rnd_init_mutex);
32 }
33 @@ -107,10 +107,10 @@ int _gnutls_rnd_preinit(void)
34
35 void _gnutls_rnd_deinit(void)
36 {
37 - if (rnd_initialized && _gnutls_rnd_ops.deinit != NULL) {
38 + if (atomic_load(&rnd_initialized) && _gnutls_rnd_ops.deinit != NULL) {
39 _gnutls_rnd_ops.deinit(gnutls_rnd_ctx);
40 }
41 - rnd_initialized = 0;
42 + atomic_store(&rnd_initialized, 0);
43
44 _rnd_system_entropy_deinit();
45
46 @@ -162,6 +162,6 @@ int gnutls_rnd(gnutls_rnd_level_t level,
47 **/
48 void gnutls_rnd_refresh(void)
49 {
50 - if (rnd_initialized && _gnutls_rnd_ops.rnd_refresh)
51 + if (atomic_load(&rnd_initialized) && _gnutls_rnd_ops.rnd_refresh)
52 _gnutls_rnd_ops.rnd_refresh(gnutls_rnd_ctx);
53 }

Properties

Name Value
svn:eol-style native
svn:mime-type text/plain