From a4021d9be4aeac7429bf6a8e9f336dbb62cacfc4 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 8 Mar 2021 21:40:50 +0100 Subject: [PATCH] sm: Init nPth which might be used by some helper code. * sm/gpgsm.c: Include npth.h. (main): Init nPth. -- Actually we currently do not use extra threads but we need to link to the npth version of the common functions because there is an option to use threads. Now, without initialized npth, we could experience a crash in gnupg_sleep, which uses npth_usleep in the npth based common functions. Fixes-commit: 046f419f806036248c058c4bd44368f8596287b7 --- sm/gpgsm.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sm/gpgsm.c b/sm/gpgsm.c index 4a466050c..fd59fc7c7 100644 --- a/sm/gpgsm.c +++ b/sm/gpgsm.c @@ -29,6 +29,7 @@ #include #include /*#include */ +#include #define INCLUDED_BY_MAIN_MODULE 1 @@ -568,6 +569,10 @@ our_md_test_algo (int algo) } +/* nPth wrapper function definitions. */ +ASSUAN_SYSTEM_NPTH_IMPL; + + static char * make_libversion (const char *libname, const char *(*getfnc)(const char*)) { @@ -1624,18 +1629,22 @@ main ( int argc, char **argv) gpgrt_strusage(11), gpgrt_strusage(13), gpgrt_strusage(14) ); es_fprintf (es_stderr, "%s\n", gpgrt_strusage(15) ); } -# ifdef IS_DEVELOPMENT_VERSION +#ifdef IS_DEVELOPMENT_VERSION if (!opt.batch) { log_info ("NOTE: THIS IS A DEVELOPMENT VERSION!\n"); log_info ("It is only intended for test purposes and should NOT be\n"); log_info ("used in a production environment or with production keys!\n"); } -# endif +#endif if (may_coredump && !opt.quiet) log_info (_("WARNING: program may create a core file!\n")); + npth_init (); + assuan_set_system_hooks (ASSUAN_SYSTEM_NPTH); + gpgrt_set_syscall_clamp (npth_unprotect, npth_protect); + /* if (opt.qualsig_approval && !opt.quiet) */ /* log_info (_("This software has officially been approved to " */ /* "create and verify\n" */