pledged Firefox aborted some time ago due to mlock(2) in OpenSC's PCKS11
modules.
sthen neutered those calls and I saw PIN prompts instead of crashes.
We did however miss munlock(2) which now makes Firefox crash whenever
I proceed with the login prompt -- my initial testing was incomplete.
The sc_mem_secure_free() hunk could be simpler by using #ifndef but I
went for the same #ifdef/#else logic as used in sc_mem_secure_alloc() to
be consistent.
This prevents crashing Firefox (again).
Feedback? OK?
Index: Makefile
===================================================================
RCS file: /cvs/ports/security/opensc/Makefile,v
retrieving revision 1.61
diff -u -p -r1.61 Makefile
--- Makefile 28 Jun 2022 10:13:51 -0000 1.61
+++ Makefile 13 Oct 2022 11:36:36 -0000
@@ -1,7 +1,7 @@
COMMENT= set of libraries and utilities to access smart cards
V= 0.22.0
-REVISION= 1
+REVISION= 2
DISTNAME= opensc-${V}
SHARED_LIBS += opensc 7.3 # 8.0
Index: patches/patch-src_libopensc_sc_c
===================================================================
RCS file: /cvs/ports/security/opensc/patches/patch-src_libopensc_sc_c,v
retrieving revision 1.3
diff -u -p -r1.3 patch-src_libopensc_sc_c
--- patches/patch-src_libopensc_sc_c 28 Jun 2022 10:13:51 -0000 1.3
+++ patches/patch-src_libopensc_sc_c 13 Oct 2022 11:44:10 -0000
@@ -28,3 +28,18 @@ Index: src/libopensc/sc.c
#endif
return p;
+@@ -927,10 +931,14 @@ void *sc_mem_secure_alloc(size_t len)
+
+ void sc_mem_secure_free(void *ptr, size_t len)
+ {
++#ifdef HAVE_CALLOC_CONCEAL
++ /* do nothing */
++#else
+ #ifdef _WIN32
+ VirtualUnlock(ptr, len);
+ #else
+ munlock(ptr, len);
++#endif
+ #endif
+ free(ptr);
+ }