summaryrefslogtreecommitdiff
path: root/lib/pk11wrap
diff options
context:
space:
mode:
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>2022-03-22 17:01:53 +0000
committerMasatoshi Kimura <VYV03354@nifty.ne.jp>2022-03-22 17:01:53 +0000
commitd989ef5a6e70f54227abe5e5ea7a1efaa5c008fe (patch)
treebe393297612dd5dfe4975db8be125c861a4ed9ef /lib/pk11wrap
parente70b86ce336fbb68107a770a52f96ccbb6d0b34d (diff)
downloadnss-hg-d989ef5a6e70f54227abe5e5ea7a1efaa5c008fe.tar.gz
Bug 1757279 - Support UTF-8 library path in the module spec string. r=nss-reviewers,jschanck
Differential Revision: https://phabricator.services.mozilla.com/D139785
Diffstat (limited to 'lib/pk11wrap')
-rw-r--r--lib/pk11wrap/pk11load.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/pk11wrap/pk11load.c b/lib/pk11wrap/pk11load.c
index a318e92fa..119c8c512 100644
--- a/lib/pk11wrap/pk11load.c
+++ b/lib/pk11wrap/pk11load.c
@@ -6,6 +6,7 @@
* various PCKS #11 modules
*/
#define FORCE_PR_LOG 1
+#include "base.h"
#include "seccomon.h"
#include "pkcs11.h"
#include "secmod.h"
@@ -16,7 +17,7 @@
#include "nssilock.h"
#include "secerr.h"
#include "prenv.h"
-#include "utilparst.h"
+#include "utilpars.h"
#include "prio.h"
#include "prprf.h"
#include <stdio.h>
@@ -464,10 +465,27 @@ secmod_LoadPKCS11Module(SECMODModule *mod, SECMODModule **oldModule)
return SECFailure;
}
- /* load the library. If this succeeds, then we have to remember to
+/* load the library. If this succeeds, then we have to remember to
* unload the library if anything goes wrong from here on out...
*/
+#if defined(_WIN32)
+ if (nssUTF8_Length(mod->dllName, NULL)) {
+ wchar_t *dllNameWide = _NSSUTIL_UTF8ToWide(mod->dllName);
+ if (dllNameWide) {
+ PRLibSpec libSpec;
+ libSpec.type = PR_LibSpec_PathnameU;
+ libSpec.value.pathname_u = dllNameWide;
+ library = PR_LoadLibraryWithFlags(libSpec, 0);
+ PORT_Free(dllNameWide);
+ }
+ }
+ if (library == NULL) {
+ // fallback to system code page
+ library = PR_LoadLibrary(mod->dllName);
+ }
+#else
library = PR_LoadLibrary(mod->dllName);
+#endif // defined(_WIN32)
mod->library = (void *)library;
if (library == NULL) {