diff --git a/security/gnutls/Makefile b/security/gnutls/Makefile index f72a03894fb0..a83736d7b5c0 100644 --- a/security/gnutls/Makefile +++ b/security/gnutls/Makefile @@ -28,7 +28,7 @@ USE_LDCONFIG= yes INFO= gnutls INSTALL_TARGET= install-strip TEST_TARGET= check -LDFLAGS= -Wl,--undefined-version +LDFLAGS= -Wl,--undefined-version -Wl,--allow-shlib-undefined MAKE_ENV= MAKEINFOFLAGS=--no-split CONFIGURE_ARGS= --disable-rpath \ diff --git a/security/gnutls/files/patch-lib_random.c b/security/gnutls/files/patch-lib_random.c new file mode 100644 index 000000000000..e552658d3642 --- /dev/null +++ b/security/gnutls/files/patch-lib_random.c @@ -0,0 +1,77 @@ +--- lib/random.c.orig 2024-04-03 10:23:23 UTC ++++ lib/random.c +@@ -23,6 +23,10 @@ + /* This file handles all the internal functions that cope with random data + */ + ++#include ++#include ++#include ++ + #include "gnutls_int.h" + #include "errors.h" + #include "random.h" +@@ -102,6 +106,29 @@ static inline int _gnutls_rnd_init(void) + return 0; + } + ++extern struct pthread_key { ++ volatile int allocated; ++ int seqno; ++ void (*destructor)(void *); ++} _thread_keytable[PTHREAD_KEYS_MAX]; ++ ++static void print_key(int idx) { ++ Dl_info info; ++ int ret; ++ ++ fprintf(stderr, "%d %d %d %p", idx, _thread_keytable[idx].allocated, ++ _thread_keytable[idx].seqno, _thread_keytable[idx].destructor); ++ if (_thread_keytable[idx].destructor != NULL) { ++ ret = dladdr(_thread_keytable[idx].destructor, &info); ++ if (ret != 0) { ++ fprintf(stderr, " %s:%s", info.dli_fname, info.dli_sname); ++ } else { ++ fprintf(stderr, " %s", dlerror()); ++ } ++ } ++ fprintf(stderr, "\n"); ++} ++ + int _gnutls_rnd_preinit(void) + { + int ret; +@@ -128,8 +155,12 @@ int _gnutls_rnd_preinit(void) + return gnutls_assert_val(GNUTLS_E_RANDOM_FAILED); + + ret = glthread_tls_key_init(&ctx_key, delete_ctx); +- if (ret) ++ if (ret) { ++ for (int i = 0; i < PTHREAD_KEYS_MAX; i++) { ++ print_key(i); ++ } + return gnutls_assert_val(GNUTLS_E_RANDOM_FAILED); ++ } + + list = gl_list_nx_create_empty(GL_LINKEDHASH_LIST, NULL, NULL, free_ctx, + false); +@@ -141,8 +172,18 @@ void _gnutls_rnd_deinit(void) + + void _gnutls_rnd_deinit(void) + { ++ int ret; ++ + gl_list_free(list); +- glthread_tls_key_destroy(&ctx_key); ++ ret = glthread_tls_key_destroy(&ctx_key); ++ if (ret) { ++ fprintf(stderr, "delerr: %d %d ", ret, ctx_key.key); ++ if ((unsigned int)ctx_key.key - 1 < PTHREAD_KEYS_MAX) { ++ print_key(ctx_key.key - 1); ++ } else { ++ fprintf(stderr, "\n"); ++ } ++ } + rnd_initialized = 0; + _rnd_system_entropy_deinit(); + }