summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Deiminger <tobias.deiminger@posteo.de>2023-01-09 21:00:06 +0100
committerTobias Deiminger <tobias.deiminger@posteo.de>2023-01-09 21:35:50 +0100
commit4f8c8297d7190480500cdafe52c8777202229b30 (patch)
tree1443484bf6c9d995c2150ca81ccf7fabeb24134f
parent4259ff0c2067d302f97d87221a442eec8e88d45c (diff)
Fix segfault on wrong nssdir
If SignatureHandler was used with a custom DB directory, but that directory didn't exist or contained no valid DB, NSS crashed on subsequent calls. We can prevent crashes by calling NSS_NoDB_Init (as it's already done in the default-DB case). Fixes #1331.
-rw-r--r--poppler/SignatureHandler.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/poppler/SignatureHandler.cc b/poppler/SignatureHandler.cc
index e0579cae..f9dd6c2f 100644
--- a/poppler/SignatureHandler.cc
+++ b/poppler/SignatureHandler.cc
@@ -769,15 +769,15 @@ void SignatureHandler::setNSSDir(const GooString &nssDir)
homeNssDb.append("/.pki/nssdb");
initSuccess = (NSS_Init(homeNssDb.c_str()) == SECSuccess);
sNssDir = homeNssDb.toStr();
- if (!initSuccess) {
- NSS_NoDB_Init(nullptr);
- }
}
}
if (initSuccess) {
// Make sure NSS root certificates module is loaded
SECMOD_AddNewModule("Root Certs", "libnssckbi.so", 0, 0);
+ } else {
+ fprintf(stderr, "NSS_Init failed: %s\n", PR_ErrorToString(PORT_GetError(), PR_LANGUAGE_I_DEFAULT));
+ NSS_NoDB_Init(nullptr);
}
}