summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorTobias Krause <tkr@openoffice.org>2011-02-14 11:28:12 +0100
committerTobias Krause <tkr@openoffice.org>2011-02-14 11:28:12 +0100
commit4b0358a8edfd003eaf054e1b333661b09213f708 (patch)
treee2c159c8da9d76f19f5fdcf6ef8c6d051a5d808f /xmlsecurity
parentd5feca7dcd9b2de4332c6b53657f6f5acbeb7b9a (diff)
tkr38: fixed broken error text print out if nss init fails (PR_GetErrorText doesn't allow NULL parameter)
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx28
1 files changed, 15 insertions, 13 deletions
diff --git a/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx
index 127d7fa43fe6..e42d97ebc756 100644
--- a/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx
@@ -171,6 +171,19 @@ void deleteRootsModule()
}
}
+namespace{
+ void getAndPrintPRErrorText()
+ {
+ char error[1024] = "Cannot get error text from function PR_GetErrorText().";
+ PRInt32 size = PR_GetErrorTextLength();
+ if (size < (int) sizeof(error))
+ {
+ PR_GetErrorText(error);
+ }
+ xmlsec_trace("%s",error);
+ }
+}
+
//Older versions of Firefox (FF), for example FF2, and Thunderbird (TB) 2 write
//the roots certificate module (libnssckbi.so), which they use, into the
//profile. This module will then already be loaded during NSS_Init (and the
@@ -206,11 +219,7 @@ bool nsscrypto_initialize( const char* token, bool & out_nss_init )
if( NSS_InitReadWrite( token ) != SECSuccess )
{
xmlsec_trace("Initializing NSS with profile failed.");
- char * error = NULL;
-
- PR_GetErrorText(error);
- if (error)
- xmlsec_trace("%s",error);
+ getAndPrintPRErrorText();
return false ;
}
}
@@ -220,10 +229,7 @@ bool nsscrypto_initialize( const char* token, bool & out_nss_init )
if ( NSS_NoDB_Init(NULL) != SECSuccess )
{
xmlsec_trace("Initializing NSS without profile failed.");
- char * error = NULL;
- PR_GetErrorText(error);
- if (error)
- xmlsec_trace("%s",error);
+ getAndPrintPRErrorText();
return false ;
}
}
@@ -296,7 +302,6 @@ bool nsscrypto_initialize( const char* token, bool & out_nss_init )
return return_value;
}
-
// must be extern "C" because we pass the function pointer to atexit
extern "C" void nsscrypto_finalize()
{
@@ -410,19 +415,16 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL
rtl::OUString ouCertDir;
-
if ( getMozillaCurrentProfile(mxMSF, ouCertDir) )
*pDefaultCertDir = rtl::OString(ouCertDir, ouCertDir.getLength(), RTL_TEXTENCODING_ASCII_US);
}
sCertDir = *pDefaultCertDir;
}
-
if( ! *initNSS( sCertDir.getStr() ) )
{
return NULL;
}
-
pCertHandle = CERT_GetDefaultCertDB() ;
try