View | Details | Raw Unified | Return to bug 278076 | Differences between
and this patch

Collapse All | Expand All

(-)b/security/gnutls/Makefile (-1 / +1 lines)
Lines 28-34 USE_LDCONFIG= yes Link Here
28
INFO=		gnutls
28
INFO=		gnutls
29
INSTALL_TARGET=	install-strip
29
INSTALL_TARGET=	install-strip
30
TEST_TARGET=	check
30
TEST_TARGET=	check
31
LDFLAGS=	-Wl,--undefined-version
31
LDFLAGS=	-Wl,--undefined-version -Wl,--allow-shlib-undefined
32
MAKE_ENV=	MAKEINFOFLAGS=--no-split
32
MAKE_ENV=	MAKEINFOFLAGS=--no-split
33
33
34
CONFIGURE_ARGS=	--disable-rpath \
34
CONFIGURE_ARGS=	--disable-rpath \
(-)b/security/gnutls/files/patch-lib_random.c (+77 lines)
Added Link Here
1
--- lib/random.c.orig	2024-04-03 10:23:23 UTC
2
+++ lib/random.c
3
@@ -23,6 +23,10 @@
4
 /* This file handles all the internal functions that cope with random data
5
  */
6
 
7
+#include <dlfcn.h>
8
+#include <pthread.h>
9
+#include <stdio.h>
10
+
11
 #include "gnutls_int.h"
12
 #include "errors.h"
13
 #include "random.h"
14
@@ -102,6 +106,29 @@ static inline int _gnutls_rnd_init(void)
15
 	return 0;
16
 }
17
 
18
+extern struct pthread_key {
19
+	volatile int	allocated;
20
+	int		seqno;
21
+	void		(*destructor)(void *);
22
+} _thread_keytable[PTHREAD_KEYS_MAX];
23
+
24
+static void print_key(int idx) {
25
+	Dl_info info;
26
+	int ret;
27
+
28
+	fprintf(stderr, "%d %d %d %p", idx, _thread_keytable[idx].allocated,
29
+		_thread_keytable[idx].seqno, _thread_keytable[idx].destructor);
30
+	if (_thread_keytable[idx].destructor != NULL) {
31
+		ret = dladdr(_thread_keytable[idx].destructor, &info);
32
+		if (ret != 0) {
33
+			fprintf(stderr, " %s:%s", info.dli_fname, info.dli_sname);
34
+		} else {
35
+			fprintf(stderr, " %s", dlerror());
36
+		}
37
+	}
38
+	fprintf(stderr, "\n");
39
+}
40
+
41
 int _gnutls_rnd_preinit(void)
42
 {
43
 	int ret;
44
@@ -128,8 +155,12 @@ int _gnutls_rnd_preinit(void)
45
 		return gnutls_assert_val(GNUTLS_E_RANDOM_FAILED);
46
 
47
 	ret = glthread_tls_key_init(&ctx_key, delete_ctx);
48
-	if (ret)
49
+	if (ret) {
50
+		for (int i = 0; i < PTHREAD_KEYS_MAX; i++) {
51
+			print_key(i);
52
+		}
53
 		return gnutls_assert_val(GNUTLS_E_RANDOM_FAILED);
54
+	}
55
 
56
 	list = gl_list_nx_create_empty(GL_LINKEDHASH_LIST, NULL, NULL, free_ctx,
57
 				       false);
58
@@ -141,8 +172,18 @@ void _gnutls_rnd_deinit(void)
59
 
60
 void _gnutls_rnd_deinit(void)
61
 {
62
+	int ret;
63
+
64
 	gl_list_free(list);
65
-	glthread_tls_key_destroy(&ctx_key);
66
+	ret = glthread_tls_key_destroy(&ctx_key);
67
+	if (ret) {
68
+		fprintf(stderr, "delerr: %d %d ", ret, ctx_key.key);
69
+		if ((unsigned int)ctx_key.key - 1 < PTHREAD_KEYS_MAX) {
70
+			print_key(ctx_key.key - 1);
71
+		} else {
72
+		    fprintf(stderr, "\n");
73
+		}
74
+	}
75
 	rnd_initialized = 0;
76
 	_rnd_system_entropy_deinit();
77
 }

Return to bug 278076