Skip to content

Commit 54313f2

Browse files
olszomalmtrojnar
authored andcommitted
Add PKCS11_FORCE_CLEANUP option to control shutdown behavior at exit
1 parent 3952112 commit 54313f2

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ New in 0.4.14; unreleased
44
* Added support for the "pkcs11prov" provider with OpenSSL 3.0
55
(Małgorzata Olszówka)
66
* Removed support for OpenSSL older than 1.0.2 (Michał Trojnara)
7+
* Added PKCS11_FORCE_CLEANUP to force cleanup on exit and avoid memory leaks
8+
with certain PKCS#11 modules
79

810
New in 0.4.13; 2024-12-13; Michał Trojnara
911
* Increased maximum PIN length (Michał Trojnara)

src/provider.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ typedef struct {
143143
void *ui_method_data;
144144
} PASSPHRASE_DATA;
145145

146-
#if defined(_WIN32) || defined(_WIN64)
147-
#define strcasecmp _stricmp
148-
#endif
149-
150146
/******************************************************************************/
151147
/* Utility functions */
152148
/******************************************************************************/

src/util.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
#include "config.h"
4747
#endif
4848

49+
#if defined(_WIN32) || defined(_WIN64)
50+
#define strcasecmp _stricmp
51+
#endif
52+
4953
/* defined in util_uri.c */
5054
typedef struct util_ctx_st UTIL_CTX; /* opaque */
5155

src/util_uri.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ static int util_ctx_enumerate_slots_unlocked(UTIL_CTX *ctx)
150150
*/
151151
static void exit_callback(void)
152152
{
153+
const char *str = getenv("PKCS11_FORCE_CLEANUP");
154+
155+
if (str && (!strcmp(str, "1") || !strcasecmp(str, "yes")))
156+
return;
153157
g_shutdown_mode = 1;
154158
}
155159

0 commit comments

Comments
 (0)