sot/source/base/formats.cxx | 2 svl/source/config/languageoptions.cxx | 6 svl/source/svdde/ddecli.cxx | 42 - svl/source/svdde/ddedata.cxx | 16 svl/source/svdde/ddeimp.hxx | 12 svl/source/svdde/ddestrg.cxx | 6 svl/source/svdde/ddesvr.cxx | 99 +-- svtools/source/misc/transfer.cxx | 8 xmlhelp/source/cxxhelp/provider/databases.cxx | 4 xmlsecurity/source/xmlsec/biginteger.cxx | 2 xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx | 10 xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.hxx | 14 xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx | 266 +++++----- xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.hxx | 32 - xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx | 26 xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.hxx | 14 xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx | 94 +-- xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.hxx | 4 xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.cxx | 58 +- xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.hxx | 12 xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.cxx | 6 xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.hxx | 20 xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx | 36 - xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.hxx | 12 xmlsecurity/source/xmlsec/mscrypt/xsec_mscrypt.cxx | 14 xmlsecurity/source/xmlsec/nss/xsec_nss.cxx | 2 xmlsecurity/source/xmlsec/xsec_xmlsec.cxx | 2 27 files changed, 411 insertions(+), 408 deletions(-)
New commits: commit 81dde672f15965cf77b041c1991bd260c4774278 Author: Stephan Bergmann <[email protected]> Date: Fri Oct 14 16:43:24 2016 +0200 clang-cl loplugin: xmlhelp Change-Id: I66956b57b542bd6375ae113ff7cc8856fa6235cd Reviewed-on: https://gerrit.libreoffice.org/29839 Tested-by: Jenkins <[email protected]> Reviewed-by: Stephan Bergmann <[email protected]> diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx index 4371cfb..d0c51b2 100644 --- a/xmlhelp/source/cxxhelp/provider/databases.cxx +++ b/xmlhelp/source/cxxhelp/provider/databases.cxx @@ -980,13 +980,13 @@ void Databases::cascadingStylesheet( const OUString& Language, { aCSS = "highcontrastblack"; #ifdef _WIN32 - HKEY hKey = NULL; + HKEY hKey = nullptr; LONG lResult = RegOpenKeyExA( HKEY_CURRENT_USER, "Control Panel\\Accessibility\\HighContrast", 0, KEY_QUERY_VALUE, &hKey ); if ( ERROR_SUCCESS == lResult ) { CHAR szBuffer[1024]; DWORD nSize = sizeof( szBuffer ); - lResult = RegQueryValueExA( hKey, "High Contrast Scheme", NULL, NULL, (LPBYTE)szBuffer, &nSize ); + lResult = RegQueryValueExA( hKey, "High Contrast Scheme", nullptr, nullptr, reinterpret_cast<LPBYTE>(szBuffer), &nSize ); if ( ERROR_SUCCESS == lResult && nSize > 0 ) { szBuffer[nSize] = '\0'; commit 5a4325ea23b36da5facb0163cd940f900fa28a3b Author: Stephan Bergmann <[email protected]> Date: Fri Oct 14 16:51:53 2016 +0200 clang-cl loplugin: sot Change-Id: I5f6db6802c99568255832fc94b72d1df38a6460c Reviewed-on: https://gerrit.libreoffice.org/29849 Tested-by: Jenkins <[email protected]> Reviewed-by: Stephan Bergmann <[email protected]> diff --git a/sot/source/base/formats.cxx b/sot/source/base/formats.cxx index 12ca819..55211eb 100644 --- a/sot/source/base/formats.cxx +++ b/sot/source/base/formats.cxx @@ -1391,7 +1391,7 @@ static bool CheckTransferableContext_Impl( const Reference< XTransferable >* pxT if( aSeq.getLength() ) { - FILEGROUPDESCRIPTOR* pFDesc = (FILEGROUPDESCRIPTOR*) aSeq.getConstArray(); + FILEGROUPDESCRIPTOR const * pFDesc = reinterpret_cast<FILEGROUPDESCRIPTOR const *>(aSeq.getConstArray()); if( pFDesc->cItems ) { commit 6e64342d34f97db9dcb70426d44c0fb5efec4fc0 Author: Stephan Bergmann <[email protected]> Date: Fri Oct 14 16:46:54 2016 +0200 clang-cl loplugin: svl The DdeInternal::Cli/SrvCallback functions apparently had broken signatures for 64-bit Windows (32-bit DWORD vs. 64-bit ULONG_PTR parameters), but I assume that was actually harmless, as I think that, for Windows x86-64, those arguments are pushed on the stack right-to-left (regardless of CALLBACK), and they are the last arguments, and SrvCallback doesn't look at them at all, and CliCallback only looks at the lower 32-bit DWORD of the first one (nInfo1). Change-Id: Id77749dd2d29180e2d11b0ae2ad248ac1a7f1bdf Reviewed-on: https://gerrit.libreoffice.org/29848 Tested-by: Jenkins <[email protected]> Reviewed-by: Stephan Bergmann <[email protected]> diff --git a/svl/source/config/languageoptions.cxx b/svl/source/config/languageoptions.cxx index bee71bb..8757244 100644 --- a/svl/source/config/languageoptions.cxx +++ b/svl/source/config/languageoptions.cxx @@ -226,17 +226,17 @@ bool SvtSystemLanguageOptions::isKeyboardLayoutTypeInstalled(sal_Int16 scriptTyp { bool isInstalled = false; #ifdef _WIN32 - int nLayouts = GetKeyboardLayoutList(0, NULL); + int nLayouts = GetKeyboardLayoutList(0, nullptr); if (nLayouts > 0) { - HKL *lpList = (HKL*)LocalAlloc(LPTR, (nLayouts * sizeof(HKL))); + HKL *lpList = static_cast<HKL*>(LocalAlloc(LPTR, (nLayouts * sizeof(HKL)))); if (lpList) { nLayouts = GetKeyboardLayoutList(nLayouts, lpList); for(int i = 0; i < nLayouts; ++i) { - LCID lang = MAKELCID((WORD)((DWORD_PTR)lpList[i] & 0xffff), SORT_DEFAULT); + LCID lang = MAKELCID((WORD)(reinterpret_cast<DWORD_PTR>(lpList[i]) & 0xffff), SORT_DEFAULT); if (MsLangId::getScriptType(lang) == scriptType) { isInstalled = true; diff --git a/svl/source/svdde/ddecli.cxx b/svl/source/svdde/ddecli.cxx index 7d290e9..c9f9b07 100644 --- a/svl/source/svdde/ddecli.cxx +++ b/svl/source/svdde/ddecli.cxx @@ -48,7 +48,7 @@ DdeInstData* ImpInitInstData() void ImpDeinitInstData() { delete theDdeInstData; - theDdeInstData = 0; + theDdeInstData = nullptr; } @@ -58,13 +58,13 @@ struct DdeImp long nStatus; }; -HDDEDATA CALLBACK DdeInternal::CliCallback( WORD nCode, WORD nCbType, +HDDEDATA CALLBACK DdeInternal::CliCallback( UINT nCode, UINT nCbType, HCONV hConv, HSZ, HSZ hText2, - HDDEDATA hData, DWORD nInfo1, DWORD ) + HDDEDATA hData, ULONG_PTR nInfo1, ULONG_PTR ) { HDDEDATA nRet = DDE_FNOTPROCESSED; const std::vector<DdeConnection*> &rAll = DdeConnection::GetConnections(); - DdeConnection* self = 0; + DdeConnection* self = nullptr; DdeInstData* pInst = ImpGetInstData(); assert(pInst); @@ -90,7 +90,7 @@ HDDEDATA CALLBACK DdeInternal::CliCallback( WORD nCode, WORD nCbType, { nCode = (*iter)->nType & (XCLASS_MASK | XTYP_MASK); (*iter)->bBusy = false; - (*iter)->Done( 0 != hData ); + (*iter)->Done( nullptr != hData ); bFound = true; } break; @@ -101,7 +101,7 @@ HDDEDATA CALLBACK DdeInternal::CliCallback( WORD nCode, WORD nCbType, ? DMLERR_NO_ERROR : DdeGetLastError( pInst->hDdeInstCli ); iter = self->aTransactions.end(); - nRet = 0; + nRet = nullptr; bFound = true; break; @@ -121,7 +121,7 @@ HDDEDATA CALLBACK DdeInternal::CliCallback( WORD nCode, WORD nCbType, if( !hData ) { static_cast<DdeLink*>(*iter)->Notify(); - nRet = (HDDEDATA)DDE_FACK; + nRet = reinterpret_cast<HDDEDATA>(DDE_FACK); break; } SAL_FALLTHROUGH; @@ -137,7 +137,7 @@ HDDEDATA CALLBACK DdeInternal::CliCallback( WORD nCode, WORD nCbType, d.pImp->nFmt = DdeData::GetInternalFormat( nCbType ); d.Lock(); (*iter)->Data( &d ); - nRet = (HDDEDATA)DDE_FACK; + nRet = reinterpret_cast<HDDEDATA>(DDE_FACK); break; } } @@ -149,7 +149,7 @@ DdeConnection::DdeConnection( const OUString& rService, const OUString& rTopic ) { pImp = new DdeImp; pImp->nStatus = DMLERR_NO_ERROR; - pImp->hConv = NULL; + pImp->hConv = nullptr; DdeInstData* pInst = ImpGetInstData(); if( !pInst ) @@ -159,7 +159,7 @@ DdeConnection::DdeConnection( const OUString& rService, const OUString& rTopic ) if ( !pInst->hDdeInstCli ) { pImp->nStatus = DdeInitialize( &pInst->hDdeInstCli, - (PFNCALLBACK)DdeInternal::CliCallback, + DdeInternal::CliCallback, APPCLASS_STANDARD | APPCMD_CLIENTONLY | CBF_FAIL_ALLSVRXACTIONS | CBF_SKIP_REGISTRATIONS | @@ -171,7 +171,7 @@ DdeConnection::DdeConnection( const OUString& rService, const OUString& rTopic ) if ( pImp->nStatus == DMLERR_NO_ERROR ) { - pImp->hConv = DdeConnect( pInst->hDdeInstCli,pService->getHSZ(),pTopic->getHSZ(), NULL); + pImp->hConv = DdeConnect( pInst->hDdeInstCli,pService->getHSZ(),pTopic->getHSZ(), nullptr); if( !pImp->hConv ) pImp->nStatus = DdeGetLastError( pInst->hDdeInstCli ); } @@ -272,25 +272,25 @@ DdeTransaction::~DdeTransaction() void DdeTransaction::Execute() { HSZ hItem = pName->getHSZ(); - void* pData = (void*)aDdeData.getData(); + void const * pData = aDdeData.getData(); DWORD nData = (DWORD)aDdeData.getSize(); SotClipboardFormatId nIntFmt = aDdeData.pImp->nFmt; UINT nExtFmt = DdeData::GetExternalFormat( nIntFmt ); DdeInstData* pInst = ImpGetInstData(); if ( nType == XTYP_EXECUTE ) - hItem = NULL; + hItem = nullptr; if ( nType != XTYP_EXECUTE && nType != XTYP_POKE ) { - pData = NULL; + pData = nullptr; nData = 0L; } if ( nTime ) { - HDDEDATA hData = DdeClientTransaction( (unsigned char*)pData, + HDDEDATA hData = DdeClientTransaction( static_cast<LPBYTE>(const_cast<void *>(pData)), nData, rDde.pImp->hConv, hItem, nExtFmt, (UINT)nType, - (DWORD)nTime, (DWORD FAR*)NULL ); + (DWORD)nTime, nullptr ); rDde.pImp->nStatus = DdeGetLastError( pInst->hDdeInstCli ); if( hData && nType == XTYP_REQUEST ) @@ -311,10 +311,12 @@ void DdeTransaction::Execute() DdeAbandonTransaction( pInst->hDdeInstCli, rDde.pImp->hConv, nId); nId = 0; bBusy = true; - HDDEDATA hRet = DdeClientTransaction( (unsigned char*)pData, nData, + DWORD result; + HDDEDATA hRet = DdeClientTransaction( static_cast<LPBYTE>(const_cast<void *>(pData)), nData, rDde.pImp->hConv, hItem, nExtFmt, (UINT)nType, TIMEOUT_ASYNC, - (DWORD FAR *) ((long*) &nId) ); + &result ); + nId = result; rDde.pImp->nStatus = hRet ? DMLERR_NO_ERROR : DdeGetLastError( pInst->hDdeInstCli ); } @@ -356,7 +358,7 @@ DdeLink::~DdeLink() void DdeLink::Notify() { - aNotify.Call( NULL ); + aNotify.Call( nullptr ); } DdeRequest::DdeRequest( DdeConnection& d, const OUString& i, long n ) @@ -382,7 +384,7 @@ DdePoke::DdePoke( DdeConnection& d, const OUString& i, const DdeData& rData, DdeExecute::DdeExecute( DdeConnection& d, const OUString& rData, long n ) : DdeTransaction( d, OUString(), n ) { - aDdeData = DdeData( (void*)rData.getStr(), sizeof(sal_Unicode) * (rData.getLength() + 1), SotClipboardFormatId::STRING ); + aDdeData = DdeData( rData.getStr(), sizeof(sal_Unicode) * (rData.getLength() + 1), SotClipboardFormatId::STRING ); nType = XTYP_EXECUTE; } diff --git a/svl/source/svdde/ddedata.cxx b/svl/source/svdde/ddedata.cxx index 71d41b8..ccfc5a3 100644 --- a/svl/source/svdde/ddedata.cxx +++ b/svl/source/svdde/ddedata.cxx @@ -33,17 +33,17 @@ DdeData::DdeData() { pImp = new DdeDataImp; - pImp->hData = NULL; + pImp->hData = nullptr; pImp->nData = 0; - pImp->pData = NULL; + pImp->pData = nullptr; pImp->nFmt = SotClipboardFormatId::STRING; } DdeData::DdeData(const void* p, long n, SotClipboardFormatId f) { pImp = new DdeDataImp; - pImp->hData = NULL; - pImp->pData = (LPBYTE)p; + pImp->hData = nullptr; + pImp->pData = p; pImp->nData = n; pImp->nFmt = f; } @@ -51,8 +51,8 @@ DdeData::DdeData(const void* p, long n, SotClipboardFormatId f) DdeData::DdeData( const OUString& s ) { pImp = new DdeDataImp; - pImp->hData = NULL; - pImp->pData = (LPBYTE)s.getStr(); + pImp->hData = nullptr; + pImp->pData = s.getStr(); pImp->nData = s.getLength()+1; pImp->nFmt = SotClipboardFormatId::STRING; } @@ -77,7 +77,7 @@ DdeData::~DdeData() void DdeData::Lock() { if ( pImp->hData ) - pImp->pData = DdeAccessData( pImp->hData, (LPDWORD) &pImp->nData ); + pImp->pData = DdeAccessData( pImp->hData, &pImp->nData ); } SotClipboardFormatId DdeData::GetFormat() const @@ -107,7 +107,7 @@ DdeData& DdeData::operator = ( const DdeData& rData ) DdeData tmp( rData ); delete pImp; pImp = tmp.pImp; - tmp.pImp = NULL; + tmp.pImp = nullptr; } return *this; diff --git a/svl/source/svdde/ddeimp.hxx b/svl/source/svdde/ddeimp.hxx index 37f3447..e502978 100644 --- a/svl/source/svdde/ddeimp.hxx +++ b/svl/source/svdde/ddeimp.hxx @@ -41,9 +41,9 @@ class DdeInternal { public: static HDDEDATA CALLBACK CliCallback - ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD ); + ( UINT, UINT, HCONV, HSZ, HSZ, HDDEDATA, ULONG_PTR, ULONG_PTR ); static HDDEDATA CALLBACK SvrCallback - ( WORD, WORD, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD ); + ( UINT, UINT, HCONV, HSZ, HSZ, HDDEDATA, ULONG_PTR, ULONG_PTR ); static DdeService* FindService( HSZ ); static DdeTopic* FindTopic( DdeService&, HSZ ); static DdeItem* FindItem( DdeTopic&, HSZ ); @@ -66,7 +66,7 @@ public: DdeString( DWORD, const OUString& ); ~DdeString(); - int operator==( HSZ ); + bool operator==( HSZ ); HSZ getHSZ(); OUString toOUString() const { return m_aString; } }; @@ -75,8 +75,8 @@ public: struct DdeDataImp { HDDEDATA hData; - LPBYTE pData; - long nData; + void const * pData; + DWORD nData; SotClipboardFormatId nFmt; }; @@ -99,7 +99,7 @@ public: : nRefCount(0) , hDdeInstSvr(0) , nInstanceSvr(0) - , pServicesSvr(NULL) + , pServicesSvr(nullptr) , hDdeInstCli(0) , nInstanceCli(0) { diff --git a/svl/source/svdde/ddestrg.cxx b/svl/source/svdde/ddestrg.cxx index e224b83..cebc935 100644 --- a/svl/source/svdde/ddestrg.cxx +++ b/svl/source/svdde/ddestrg.cxx @@ -26,14 +26,14 @@ DdeString::DdeString( DWORD hDdeInst, const sal_Unicode* p ) : m_aString(p) { - hString = DdeCreateStringHandle( hDdeInst, (LPTSTR)p, CP_WINUNICODE ); + hString = DdeCreateStringHandle( hDdeInst, p, CP_WINUNICODE ); hInst = hDdeInst; } DdeString::DdeString( DWORD hDdeInst, const OUString& r) : m_aString(r) { - hString = DdeCreateStringHandle( hDdeInst, (LPTSTR)r.getStr(), CP_WINUNICODE ); + hString = DdeCreateStringHandle( hDdeInst, r.getStr(), CP_WINUNICODE ); hInst = hDdeInst; } @@ -43,7 +43,7 @@ DdeString::~DdeString() DdeFreeStringHandle( hInst, hString ); } -int DdeString::operator==( HSZ h ) +bool DdeString::operator==( HSZ h ) { return( !DdeCmpStringHandles( hString, h ) ); } diff --git a/svl/source/svdde/ddesvr.cxx b/svl/source/svdde/ddesvr.cxx index 4205a05..4235c78 100644 --- a/svl/source/svdde/ddesvr.cxx +++ b/svl/source/svdde/ddesvr.cxx @@ -60,8 +60,8 @@ private: }; HDDEDATA CALLBACK DdeInternal::SvrCallback( - WORD nCode, WORD nCbType, HCONV hConv, HSZ hText1, HSZ hText2, - HDDEDATA hData, DWORD, DWORD ) + UINT nCode, UINT nCbType, HCONV hConv, HSZ hText1, HSZ hText2, + HDDEDATA hData, ULONG_PTR, ULONG_PTR ) { DdeServices& rAll = DdeService::GetServices(); DdeService* pService; @@ -109,7 +109,7 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback( } if( !nTopics ) - return (HDDEDATA)NULL; + return nullptr; HSZPAIR* pPairs = new HSZPAIR [nTopics + 1]; @@ -140,12 +140,12 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback( } } - q->hszSvc = NULL; - q->hszTopic = NULL; + q->hszSvc = nullptr; + q->hszTopic = nullptr; HDDEDATA h = DdeCreateDataHandle( - pInst->hDdeInstSvr, (LPBYTE) pPairs, + pInst->hDdeInstSvr, reinterpret_cast<LPBYTE>(pPairs), sizeof(HSZPAIR) * (nTopics+1), - 0, NULL, nCbType, 0); + 0, nullptr, nCbType, 0); delete [] pPairs; return h; } @@ -155,11 +155,11 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback( if ( pService) pTopic = FindTopic( *pService, hText1 ); else - pTopic = NULL; + pTopic = nullptr; if ( pTopic ) - return (HDDEDATA)DDE_FACK; + return reinterpret_cast<HDDEDATA>(DDE_FACK); else - return (HDDEDATA) NULL; + return nullptr; case XTYP_CONNECT_CONFIRM: pService = FindService( hText2 ); @@ -174,7 +174,7 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback( pService->pConv->push_back( pC ); } } - return (HDDEDATA)NULL; + return nullptr; } for (DdeServices::iterator aI = rAll.begin(); aI != rAll.end(); ++aI) @@ -188,7 +188,7 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback( } } - return (HDDEDATA) DDE_FNOTPROCESSED; + return reinterpret_cast<HDDEDATA>(DDE_FNOTPROCESSED); found: if ( nCode == XTYP_DISCONNECT) @@ -205,7 +205,7 @@ found: break; } } - return (HDDEDATA)NULL; + return nullptr; } bool bExec = nCode == XTYP_EXECUTE; @@ -213,12 +213,12 @@ found: if ( pTopic && !bExec ) pItem = FindItem( *pTopic, hText2 ); else - pItem = NULL; + pItem = nullptr; if ( !bExec && !pService->HasCbFormat( nCbType ) ) - pItem = NULL; + pItem = nullptr; if ( !pItem && !bExec ) - return (HDDEDATA)DDE_FNOTPROCESSED; + return static_cast<HDDEDATA>(DDE_FNOTPROCESSED); if ( pItem ) pTopic->aItem = pItem->GetName(); else @@ -249,11 +249,11 @@ found: if ( !aRes.isEmpty() ) pData = new DdeData( aRes ); else - pData = NULL; + pData = nullptr; } else if( DDEGETPUTITEM == pItem->nType ) { - pData = ((DdeGetPutItem*)pItem)->Get( DdeData::GetInternalFormat( nCbType ) ); + pData = static_cast<DdeGetPutItem*>(pItem)->Get( DdeData::GetInternalFormat( nCbType ) ); } else { @@ -263,7 +263,7 @@ found: if ( pData ) { return DdeCreateDataHandle( pInst->hDdeInstSvr, - (LPBYTE)pData->pImp->pData, + static_cast<LPBYTE>(const_cast<void *>(pData->pImp->pData)), pData->pImp->nData, 0, hText2, DdeData::GetExternalFormat( @@ -281,14 +281,14 @@ found: d.pImp->nFmt = DdeData::GetInternalFormat( nCbType ); d.Lock(); if( DDEGETPUTITEM == pItem->nType ) - bRes = ((DdeGetPutItem*)pItem)->Put( &d ); + bRes = static_cast<DdeGetPutItem*>(pItem)->Put( &d ); else bRes = pTopic->Put( &d ); } if ( bRes ) - return (HDDEDATA)DDE_FACK; + return reinterpret_cast<HDDEDATA>(DDE_FACK); else - return (HDDEDATA) DDE_FNOTPROCESSED; + return reinterpret_cast<HDDEDATA>(DDE_FNOTPROCESSED); case XTYP_ADVSTART: { @@ -311,7 +311,7 @@ found: { // It was exchanged indeed delete pItem; - pItem = 0; + pItem = nullptr; break; } } @@ -320,7 +320,7 @@ found: // It was not exchange, so back in pTopic->aItems.push_back(pItem); else - pItem = iter != pTopic->aItems.end() ? *iter : NULL; + pItem = iter != pTopic->aItems.end() ? *iter : nullptr; } if (pItem) @@ -328,11 +328,11 @@ found: IncMonitor(pItem, hConv); } } - return (HDDEDATA)sal_True; + return reinterpret_cast<HDDEDATA>(TRUE); case XTYP_ADVSTOP: DecMonitor(pItem, hConv); - return (HDDEDATA)sal_True; + return reinterpret_cast<HDDEDATA>(TRUE); case XTYP_EXECUTE: { @@ -342,7 +342,7 @@ found: aExec.Lock(); OUString aName; - aName = (const sal_Unicode *)aExec.pImp->pData; + aName = static_cast<const sal_Unicode *>(aExec.pImp->pData); if( pTopic->IsSystemTopic() ) bRes = false; @@ -350,12 +350,12 @@ found: bRes = pTopic->Execute( &aName ); } if ( bRes ) - return (HDDEDATA)DDE_FACK; + return reinterpret_cast<HDDEDATA>(DDE_FACK); else - return (HDDEDATA)DDE_FNOTPROCESSED; + return reinterpret_cast<HDDEDATA>(DDE_FNOTPROCESSED); } - return (HDDEDATA)NULL; + return nullptr; } DdeService* DdeInternal::FindService( HSZ hService ) @@ -368,7 +368,7 @@ DdeService* DdeInternal::FindService( HSZ hService ) return s; } - return NULL; + return nullptr; } DdeTopic* DdeInternal::FindTopic( DdeService& rService, HSZ hTopic ) @@ -399,7 +399,7 @@ DdeTopic* DdeInternal::FindTopic( DdeService& rService, HSZ hTopic ) } while( bContinue ); - return 0; + return nullptr; } DdeItem* DdeInternal::FindItem( DdeTopic& rTopic, HSZ hItem ) @@ -429,7 +429,7 @@ DdeItem* DdeInternal::FindItem( DdeTopic& rTopic, HSZ hItem ) } while( bContinue ); - return 0; + return nullptr; } DdeService::DdeService( const OUString& rService ) @@ -444,7 +444,7 @@ DdeService::DdeService( const OUString& rService ) { nStatus = sal::static_int_cast< short >( DdeInitialize( &pInst->hDdeInstSvr, - (PFNCALLBACK)DdeInternal::SvrCallback, + DdeInternal::SvrCallback, APPCLASS_STANDARD | CBF_SKIP_REGISTRATIONS | CBF_SKIP_UNREGISTRATIONS, 0L ) ); @@ -461,7 +461,7 @@ DdeService::DdeService( const OUString& rService ) pName = new DdeString( pInst->hDdeInstSvr, rService ); if ( nStatus == DMLERR_NO_ERROR ) { - if ( !DdeNameService( pInst->hDdeInstSvr, pName->getHSZ(), NULL, + if ( !DdeNameService( pInst->hDdeInstSvr, pName->getHSZ(), nullptr, DNS_REGISTER | DNS_FILTEROFF ) ) { nStatus = DMLERR_SYS_ERROR; @@ -495,7 +495,7 @@ DdeService::~DdeService() { pInst->hDdeInstSvr = 0; delete pInst->pServicesSvr; - pInst->pServicesSvr = NULL; + pInst->pServicesSvr = nullptr; if( pInst->nRefCount == 0) ImpDeinitInstData(); } @@ -518,7 +518,7 @@ DdeServices& DdeService::GetServices() void DdeService::AddTopic( const DdeTopic& rTopic ) { RemoveTopic( rTopic ); - aTopics.push_back((DdeTopic *) &rTopic); + aTopics.push_back(const_cast<DdeTopic *>(&rTopic)); } void DdeService::RemoveTopic( const DdeTopic& rTopic ) @@ -594,7 +594,7 @@ DdeTopic::~DdeTopic() std::vector<DdeItem*>::iterator iter; for (iter = aItems.begin(); iter != aItems.end(); ++iter) { - (*iter)->pMyTopic = 0; + (*iter)->pMyTopic = nullptr; delete *iter; } @@ -647,7 +647,7 @@ void DdeTopic::RemoveItem( const DdeItem& r ) if ( iter != aItems.end() ) { - (*iter)->pMyTopic = 0; + (*iter)->pMyTopic = nullptr; delete *iter; aItems.erase(iter); } @@ -679,7 +679,7 @@ void DdeInternal::DisconnectTopic(DdeTopic & rTopic, HCONV nId) DdeData* DdeTopic::Get(SotClipboardFormatId /*nFmt*/) { - return NULL; + return nullptr; } bool DdeTopic::Put( const DdeData* ) @@ -703,8 +703,8 @@ DdeItem::DdeItem( const sal_Unicode* p ) assert(pInst); pName = new DdeString( pInst->hDdeInstSvr, p ); nType = DDEITEM; - pMyTopic = 0; - pImpData = 0; + pMyTopic = nullptr; + pImpData = nullptr; } DdeItem::DdeItem( const OUString& r) @@ -713,8 +713,8 @@ DdeItem::DdeItem( const OUString& r) assert(pInst); pName = new DdeString( pInst->hDdeInstSvr, r ); nType = DDEITEM; - pMyTopic = 0; - pImpData = 0; + pMyTopic = nullptr; + pImpData = nullptr; } DdeItem::DdeItem( const DdeItem& r) @@ -723,8 +723,8 @@ DdeItem::DdeItem( const DdeItem& r) assert(pInst); pName = new DdeString( pInst->hDdeInstSvr, r.pName->toOUString() ); nType = DDEITEM; - pMyTopic = 0; - pImpData = 0; + pMyTopic = nullptr; + pImpData = nullptr; } DdeItem::~DdeItem() @@ -780,7 +780,7 @@ void DdeInternal::DecMonitor(DdeItem *const pItem, HCONV nHCnv) { if (pItem->pImpData) { - for( sal_uInt16 n = 0; n < pItem->pImpData->size(); ++n ) + for( size_t n = 0; n < pItem->pImpData->size(); ++n ) { DdeItemImpData* pData = &(*pItem->pImpData)[n]; if( pData->nHCnv == nHCnv ) @@ -793,7 +793,8 @@ void DdeInternal::DecMonitor(DdeItem *const pItem, HCONV nHCnv) } else { - delete pItem->pImpData, pItem->pImpData = 0; + delete pItem->pImpData; + pItem->pImpData = nullptr; if (DDEGETPUTITEM == pItem->nType) { static_cast<DdeGetPutItem*>(pItem)->AdviseLoop(false); @@ -839,7 +840,7 @@ DdeGetPutItem::DdeGetPutItem( const DdeItem& rItem ) DdeData* DdeGetPutItem::Get(SotClipboardFormatId) { - return 0; + return nullptr; } bool DdeGetPutItem::Put( const DdeData* ) commit 0deb7d16f32b4c89260f6aac29fc29f4e5bd8261 Author: Stephan Bergmann <[email protected]> Date: Fri Oct 14 16:46:13 2016 +0200 clang-cl loplugin: svtools Change-Id: I3271529ffe48ebafd203b759a72741a9bdbba506 Reviewed-on: https://gerrit.libreoffice.org/29846 Tested-by: Jenkins <[email protected]> Reviewed-by: Stephan Bergmann <[email protected]> diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx index 8efdce0..c271ecb 100644 --- a/svtools/source/misc/transfer.cxx +++ b/svtools/source/misc/transfer.cxx @@ -801,7 +801,7 @@ bool TransferableHelper::SetINetBookmark( const INetBookmark& rBmk, case SotClipboardFormatId::FILEGRPDESCRIPTOR: { Sequence< sal_Int8 > aSeq( sizeof( FILEGROUPDESCRIPTOR ) ); - FILEGROUPDESCRIPTOR* pFDesc = (FILEGROUPDESCRIPTOR*) aSeq.getArray(); + FILEGROUPDESCRIPTOR* pFDesc = reinterpret_cast<FILEGROUPDESCRIPTOR*>(aSeq.getArray()); FILEDESCRIPTOR& rFDesc1 = pFDesc->fgd[ 0 ]; pFDesc->cItems = 1; @@ -810,7 +810,7 @@ bool TransferableHelper::SetINetBookmark( const INetBookmark& rBmk, OStringBuffer aStr(OUStringToOString( rBmk.GetDescription(), eSysCSet)); - for( sal_uInt16 nChar = 0; nChar < aStr.getLength(); ++nChar ) + for( sal_Int32 nChar = 0; nChar < aStr.getLength(); ++nChar ) if( strchr( "\\/:*?\"<>|", aStr[nChar] ) ) aStr.remove(nChar--, 1); @@ -1877,7 +1877,7 @@ bool TransferableDataHelper::GetINetBookmark( const css::datatransfer::DataFlavo if (aSeq.getLength()) { - FILEGROUPDESCRIPTOR* pFDesc = (FILEGROUPDESCRIPTOR*) aSeq.getConstArray(); + FILEGROUPDESCRIPTOR const * pFDesc = reinterpret_cast<FILEGROUPDESCRIPTOR const *>(aSeq.getConstArray()); if( pFDesc->cItems ) { @@ -1900,7 +1900,7 @@ bool TransferableDataHelper::GetINetBookmark( const css::datatransfer::DataFlavo { aSeq = GetSequence(aFileContentFlavor, OUString()); if (aSeq.getLength()) - pStream.reset(new SvMemoryStream( (sal_Char*) aSeq.getConstArray(), aSeq.getLength(), StreamMode::STD_READ )); + pStream.reset(new SvMemoryStream( const_cast<sal_Int8 *>(aSeq.getConstArray()), aSeq.getLength(), StreamMode::STD_READ )); } } commit 774e51d44c3bab7652c8807bbf2ed68293b47a6e Author: Stephan Bergmann <[email protected]> Date: Fri Oct 14 16:42:51 2016 +0200 clang-cl loplugin: xmlsecurity Change-Id: Ic101384ca32abb0d527f97d2cf695eb19c66da86 Reviewed-on: https://gerrit.libreoffice.org/29838 Tested-by: Jenkins <[email protected]> Reviewed-by: Stephan Bergmann <[email protected]> diff --git a/xmlsecurity/source/xmlsec/biginteger.cxx b/xmlsecurity/source/xmlsec/biginteger.cxx index 5b7075c..331e853 100644 --- a/xmlsecurity/source/xmlsec/biginteger.cxx +++ b/xmlsecurity/source/xmlsec/biginteger.cxx @@ -64,7 +64,7 @@ Sequence< sal_Int8 > numericStringToBigInteger ( const OUString& numeral ) } Sequence< sal_Int8 > integer( length ) ; - for( unsigned int i = 0 ; i < length ; i ++ ) + for( xmlSecSize i = 0 ; i < length ; i ++ ) { integer[i] = *( bnInteger + i ) ; } diff --git a/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx index 4cc81a6..c5ce74d 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx @@ -35,7 +35,7 @@ using ::com::sun::star::security::XCertificateExtension ; SanExtensionImpl::SanExtensionImpl() : - m_critical( sal_False ) + m_critical( false ) { } @@ -63,7 +63,7 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl: { CERT_ALT_NAME_INFO *subjectName; DWORD size; - CryptDecodeObjectEx(X509_ASN_ENCODING, X509_ALTERNATE_NAME, (unsigned char*) m_xExtnValue.getArray(), m_xExtnValue.getLength(), CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG, NULL,&subjectName, &size); + CryptDecodeObjectEx(X509_ASN_ENCODING, X509_ALTERNATE_NAME, reinterpret_cast<unsigned char*>(m_xExtnValue.getArray()), m_xExtnValue.getLength(), CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG, nullptr,&subjectName, &size); CertAltNameEntry* arrCertAltNameEntry = new CertAltNameEntry[subjectName->cAltEntry]; @@ -90,11 +90,11 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl: } case CERT_ALT_NAME_RFC822_NAME : arrCertAltNameEntry[i].Type = ExtAltNameType_RFC822_NAME; - arrCertAltNameEntry[i].Value <<= OUString((const sal_Unicode*)pEntry->pwszRfc822Name); + arrCertAltNameEntry[i].Value <<= OUString(pEntry->pwszRfc822Name); break; case CERT_ALT_NAME_DNS_NAME : arrCertAltNameEntry[i].Type = ExtAltNameType_DNS_NAME; - arrCertAltNameEntry[i].Value <<= OUString((const sal_Unicode*)pEntry->pwszDNSName); + arrCertAltNameEntry[i].Value <<= OUString(pEntry->pwszDNSName); break; case CERT_ALT_NAME_DIRECTORY_NAME : { @@ -103,7 +103,7 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl: } case CERT_ALT_NAME_URL : arrCertAltNameEntry[i].Type = ExtAltNameType_URL; - arrCertAltNameEntry[i].Value <<= OUString((const sal_Unicode*)pEntry->pwszURL); + arrCertAltNameEntry[i].Value <<= OUString(pEntry->pwszURL); break; case CERT_ALT_NAME_IP_ADDRESS : { diff --git a/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.hxx b/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.hxx index 5bd90dc..c4e391a 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.hxx +++ b/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.hxx @@ -42,7 +42,7 @@ class SanExtensionImpl : public ::cppu::WeakImplHelper< css::security::XSanExtension > { private: - sal_Bool m_critical ; + bool m_critical ; css::uno::Sequence< sal_Int8 > m_xExtnId ; css::uno::Sequence< sal_Int8 > m_xExtnValue ; @@ -50,21 +50,21 @@ class SanExtensionImpl : public ::cppu::WeakImplHelper< public: SanExtensionImpl() ; - virtual ~SanExtensionImpl() ; + virtual ~SanExtensionImpl() override; //Methods from XCertificateExtension - virtual sal_Bool SAL_CALL isCritical() throw( css::uno::RuntimeException ) ; + virtual sal_Bool SAL_CALL isCritical() throw( css::uno::RuntimeException ) override; - virtual css::uno::Sequence< sal_Int8 > SAL_CALL getExtensionId() throw( css::uno::RuntimeException ) ; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getExtensionId() throw( css::uno::RuntimeException ) override; - virtual css::uno::Sequence< sal_Int8 > SAL_CALL getExtensionValue() throw( css::uno::RuntimeException ) ; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getExtensionValue() throw( css::uno::RuntimeException ) override; //Methods from XSanExtension - virtual css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL getAlternativeNames() throw( css::uno::RuntimeException ) ; + virtual css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL getAlternativeNames() throw( css::uno::RuntimeException ) override; //Helper method - void setCertExtn( unsigned char* value, unsigned int vlen, unsigned char* id, unsigned int idlen, sal_Bool critical ) ; + void setCertExtn( unsigned char* value, unsigned int vlen, unsigned char* id, unsigned int idlen, bool critical ) ; } ; #endif // INCLUDED_XMLSECURITY_SOURCE_XMLSEC_MSCRYPT_SANEXTENSION_MSCRYPTIMPL_HXX diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx index 3029545..955f0bb 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx @@ -105,7 +105,7 @@ void traceTrustStatus(DWORD err) } } -SecurityEnvironment_MSCryptImpl::SecurityEnvironment_MSCryptImpl( const Reference< XMultiServiceFactory >& aFactory ) : m_hProv( NULL ) , m_pszContainer( NULL ) , m_hKeyStore( NULL ), m_hCertStore( NULL ), m_hMySystemStore(NULL), m_hRootSystemStore(NULL), m_hTrustSystemStore(NULL), m_hCaSystemStore(NULL), m_bEnableDefault( sal_False ), m_tSymKeyList() , m_tPubKeyList() , m_tPriKeyList(), m_xServiceManager( aFactory ){ +SecurityEnvironment_MSCryptImpl::SecurityEnvironment_MSCryptImpl( const Reference< XMultiServiceFactory >& aFactory ) : m_hProv( NULL ) , m_pszContainer( nullptr ) , m_hKeyStore( nullptr ), m_hCertStore( nullptr ), m_hMySystemStore(nullptr), m_hRootSystemStore(nullptr), m_hTrustSystemStore(nullptr), m_hCaSystemStore(nullptr), m_bEnableDefault( false ), m_tSymKeyList() , m_tPubKeyList() , m_tPriKeyList(), m_xServiceManager( aFactory ){ } @@ -116,40 +116,40 @@ SecurityEnvironment_MSCryptImpl::~SecurityEnvironment_MSCryptImpl() { m_hProv = NULL ; } - if( m_pszContainer != NULL ) { + if( m_pszContainer != nullptr ) { //TODO: Don't know whether or not it should be released now. - m_pszContainer = NULL ; + m_pszContainer = nullptr ; } - if( m_hCertStore != NULL ) { + if( m_hCertStore != nullptr ) { CertCloseStore( m_hCertStore, CERT_CLOSE_STORE_FORCE_FLAG ) ; - m_hCertStore = NULL ; + m_hCertStore = nullptr ; } - if( m_hKeyStore != NULL ) { + if( m_hKeyStore != nullptr ) { CertCloseStore( m_hKeyStore, CERT_CLOSE_STORE_FORCE_FLAG ) ; - m_hKeyStore = NULL ; + m_hKeyStore = nullptr ; } //i120675, close the store handles - if( m_hMySystemStore != NULL ) { + if( m_hMySystemStore != nullptr ) { CertCloseStore( m_hMySystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; - m_hMySystemStore = NULL ; + m_hMySystemStore = nullptr ; } - if( m_hRootSystemStore != NULL ) { + if( m_hRootSystemStore != nullptr ) { CertCloseStore( m_hRootSystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; - m_hRootSystemStore = NULL ; + m_hRootSystemStore = nullptr ; } - if( m_hTrustSystemStore != NULL ) { + if( m_hTrustSystemStore != nullptr ) { CertCloseStore( m_hTrustSystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; - m_hTrustSystemStore = NULL ; + m_hTrustSystemStore = nullptr ; } - if( m_hCaSystemStore != NULL ) { + if( m_hCaSystemStore != nullptr ) { CertCloseStore( m_hCaSystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; - m_hCaSystemStore = NULL ; + m_hCaSystemStore = nullptr ; } if( !m_tSymKeyList.empty() ) { @@ -186,9 +186,9 @@ sal_Bool SAL_CALL SecurityEnvironment_MSCryptImpl::supportsService( const OUStri const OUString* pArray = seqServiceNames.getConstArray() ; for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) { if( *( pArray + i ) == serviceName ) - return sal_True ; + return true ; } - return sal_False ; + return false ; } /* XServiceInfo */ @@ -221,7 +221,7 @@ sal_Int64 SAL_CALL SecurityEnvironment_MSCryptImpl::getSomething( const Sequence throw( RuntimeException ) { if( aIdentifier.getLength() == 16 && 0 == memcmp( getUnoTunnelId().getConstArray(), aIdentifier.getConstArray(), 16 ) ) { - return ( sal_Int64 )this ; + return reinterpret_cast<sal_Int64>(this); } return 0 ; } @@ -242,9 +242,9 @@ const Sequence< sal_Int8>& SecurityEnvironment_MSCryptImpl::getUnoTunnelId() { SecurityEnvironment_MSCryptImpl* SecurityEnvironment_MSCryptImpl::getImplementation( const Reference< XInterface >& rObj ) { Reference< XUnoTunnel > xUT( rObj , UNO_QUERY ) ; if( xUT.is() ) { - return ( SecurityEnvironment_MSCryptImpl* )xUT->getSomething( getUnoTunnelId() ) ; + return reinterpret_cast<SecurityEnvironment_MSCryptImpl*>(xUT->getSomething( getUnoTunnelId() )); } else - return NULL ; + return nullptr ; } /* Native methods */ @@ -278,12 +278,12 @@ HCERTSTORE SecurityEnvironment_MSCryptImpl::getCryptoSlot() throw( Exception , R } void SecurityEnvironment_MSCryptImpl::setCryptoSlot( HCERTSTORE aSlot) throw( Exception , RuntimeException ) { - if( m_hKeyStore != NULL ) { + if( m_hKeyStore != nullptr ) { CertCloseStore( m_hKeyStore, CERT_CLOSE_STORE_FORCE_FLAG ) ; - m_hKeyStore = NULL ; + m_hKeyStore = nullptr ; } - if( aSlot != NULL ) { + if( aSlot != nullptr ) { m_hKeyStore = CertDuplicateStore( aSlot ) ; } } @@ -293,12 +293,12 @@ HCERTSTORE SecurityEnvironment_MSCryptImpl::getCertDb() throw( Exception , Runti } void SecurityEnvironment_MSCryptImpl::setCertDb( HCERTSTORE aCertDb ) throw( Exception , RuntimeException ) { - if( m_hCertStore != NULL ) { + if( m_hCertStore != nullptr ) { CertCloseStore( m_hCertStore, CERT_CLOSE_STORE_FORCE_FLAG ) ; - m_hCertStore = NULL ; + m_hCertStore = nullptr ; } - if( aCertDb != NULL ) { + if( aCertDb != nullptr ) { m_hCertStore = CertDuplicateStore( aCertDb ) ; } } @@ -375,17 +375,17 @@ static void get_system_name(const void *pvSystemStore, DWORD dwFlags, LPCWSTR *ppwszSystemName) { - *ppwszSystemName = NULL; + *ppwszSystemName = nullptr; if (dwFlags & CERT_SYSTEM_STORE_RELOCATE_FLAG) { - PCERT_SYSTEM_STORE_RELOCATE_PARA pRelocatePara; - pRelocatePara = (PCERT_SYSTEM_STORE_RELOCATE_PARA) pvSystemStore; + _CERT_SYSTEM_STORE_RELOCATE_PARA const * pRelocatePara; + pRelocatePara = static_cast<_CERT_SYSTEM_STORE_RELOCATE_PARA const *>(pvSystemStore); *ppwszSystemName = pRelocatePara->pwszSystemStore; } else { - *ppwszSystemName = (LPCWSTR) pvSystemStore; + *ppwszSystemName = static_cast<LPCWSTR>(pvSystemStore); } } @@ -417,7 +417,7 @@ extern "C" BOOL WINAPI cert_enum_system_store_callback(const void *pvSystemStore if (!CertEnumPhysicalStore(pvSystemStore, dwFlags, - NULL, + nullptr, cert_enum_physical_store_callback)) { DWORD dwErr = GetLastError(); @@ -438,15 +438,15 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_MSCryptImpl::getPerso sal_Int32 length ; X509Certificate_MSCryptImpl* xcert ; std::list< X509Certificate_MSCryptImpl* > certsList ; - PCCERT_CONTEXT pCertContext = NULL; + PCCERT_CONTEXT pCertContext = nullptr; //firstly, we try to find private keys in given key store. - if( m_hKeyStore != NULL ) { + if( m_hKeyStore != nullptr ) { pCertContext = CertEnumCertificatesInStore( m_hKeyStore, pCertContext ); while (pCertContext) { xcert = MswcryCertContextToXCert( pCertContext ) ; - if( xcert != NULL ) + if( xcert != nullptr ) certsList.push_back( xcert ) ; pCertContext = CertEnumCertificatesInStore( m_hKeyStore, pCertContext ); } @@ -464,21 +464,21 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_MSCryptImpl::getPerso HCRYPTPROV hCryptProv; #ifdef SAL_LOG_INFO - CertEnumSystemStore(CERT_SYSTEM_STORE_CURRENT_USER, NULL, NULL, cert_enum_system_store_callback); + CertEnumSystemStore(CERT_SYSTEM_STORE_CURRENT_USER, nullptr, nullptr, cert_enum_system_store_callback); #endif hSystemKeyStore = CertOpenSystemStore( 0, "MY" ) ; - if( hSystemKeyStore != NULL ) { + if( hSystemKeyStore != nullptr ) { pCertContext = CertEnumCertificatesInStore( hSystemKeyStore, pCertContext ); while (pCertContext) { // for checking whether the certificate is a personal certificate or not. if(!(CryptAcquireCertificatePrivateKey(pCertContext, CRYPT_ACQUIRE_COMPARE_KEY_FLAG, - NULL, + nullptr, &hCryptProv, &dwKeySpec, - NULL))) + nullptr))) { // Not Privatekey found. SKIP this one. pCertContext = CertEnumCertificatesInStore( hSystemKeyStore, pCertContext ); @@ -487,7 +487,7 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_MSCryptImpl::getPerso // then TODO : Check the personal cert is valid or not. xcert = MswcryCertContextToXCert( pCertContext ) ; - if( xcert != NULL ) + if( xcert != nullptr ) certsList.push_back( xcert ) ; pCertContext = CertEnumCertificatesInStore( hSystemKeyStore, pCertContext ); } @@ -515,35 +515,35 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_MSCryptImpl::getPerso Reference< XCertificate > SecurityEnvironment_MSCryptImpl::getCertificate( const OUString& issuerName, const Sequence< sal_Int8 >& serialNumber ) throw( SecurityException , RuntimeException ) { unsigned int i ; - LPSTR pszName ; - X509Certificate_MSCryptImpl *xcert = NULL ; - PCCERT_CONTEXT pCertContext = NULL ; - HCERTSTORE hCertStore = NULL ; + LPCSTR pszName ; + X509Certificate_MSCryptImpl *xcert = nullptr ; + PCCERT_CONTEXT pCertContext = nullptr ; + HCERTSTORE hCertStore = nullptr ; CRYPT_INTEGER_BLOB cryptSerialNumber ; CERT_INFO certInfo ; // for correct encoding sal_uInt16 encoding ; - rtl_Locale *pLocale = NULL ; + rtl_Locale *pLocale = nullptr ; osl_getProcessLocale( &pLocale ) ; encoding = osl_getTextEncodingFromLocale( pLocale ) ; //Create cert info from issue and serial OString oissuer = OUStringToOString( issuerName , encoding ) ; - pszName = ( char* )oissuer.getStr() ; + pszName = oissuer.getStr() ; if( ! ( CertStrToName( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , pszName , CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG | CERT_NAME_STR_ENABLE_UTF8_UNICODE_FLAG, - NULL , - NULL , - &certInfo.Issuer.cbData, NULL ) ) + nullptr , + nullptr , + &certInfo.Issuer.cbData, nullptr ) ) ) { - return NULL ; + return nullptr ; } - certInfo.Issuer.pbData = ( BYTE* )malloc( certInfo.Issuer.cbData ); + certInfo.Issuer.pbData = static_cast<BYTE*>(malloc( certInfo.Issuer.cbData )); if(!certInfo.Issuer.pbData) throw RuntimeException() ; @@ -551,17 +551,17 @@ Reference< XCertificate > SecurityEnvironment_MSCryptImpl::getCertificate( const X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , pszName , CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG | CERT_NAME_STR_ENABLE_UTF8_UNICODE_FLAG, - NULL , - ( BYTE* )certInfo.Issuer.pbData , - &certInfo.Issuer.cbData, NULL ) ) + nullptr , + certInfo.Issuer.pbData , + &certInfo.Issuer.cbData, nullptr ) ) ) { free( certInfo.Issuer.pbData ) ; - return NULL ; + return nullptr ; } //Get the SerialNumber cryptSerialNumber.cbData = serialNumber.getLength() ; - cryptSerialNumber.pbData = ( BYTE* )malloc( cryptSerialNumber.cbData); + cryptSerialNumber.pbData = static_cast<BYTE*>(malloc( cryptSerialNumber.cbData)); if (!cryptSerialNumber.pbData) { free( certInfo.Issuer.pbData ) ; @@ -579,28 +579,28 @@ Reference< XCertificate > SecurityEnvironment_MSCryptImpl::getCertificate( const switch(i) { case 0: - if(m_hKeyStore == NULL) continue ; + if(m_hKeyStore == nullptr) continue ; hCertStore = m_hKeyStore ; break; case 1: - if(m_hCertStore == NULL) continue ; + if(m_hCertStore == nullptr) continue ; hCertStore = m_hCertStore ; break; case 2: hCertStore = CertOpenSystemStore( 0, "MY" ) ; - if(hCertStore == NULL || !m_bEnableDefault) continue ; + if(hCertStore == nullptr || !m_bEnableDefault) continue ; break; case 3: hCertStore = CertOpenSystemStore( 0, "Root" ) ; - if(hCertStore == NULL || !m_bEnableDefault) continue ; + if(hCertStore == nullptr || !m_bEnableDefault) continue ; break; case 4: hCertStore = CertOpenSystemStore( 0, "Trust" ) ; - if(hCertStore == NULL || !m_bEnableDefault) continue ; + if(hCertStore == nullptr || !m_bEnableDefault) continue ; break; case 5: hCertStore = CertOpenSystemStore( 0, "CA" ) ; - if(hCertStore == NULL || !m_bEnableDefault) continue ; + if(hCertStore == nullptr || !m_bEnableDefault) continue ; break; default: i=6; @@ -689,22 +689,22 @@ Reference< XCertificate > SecurityEnvironment_MSCryptImpl::getCertificate( const 0, CERT_FIND_SUBJECT_CERT, &certInfo, - NULL + nullptr ) ; if(i != 0 && i != 1) CertCloseStore( hCertStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; - if( pCertContext != NULL ) break ; // Found the certificate. + if( pCertContext != nullptr ) break ; // Found the certificate. } if( cryptSerialNumber.pbData ) free( cryptSerialNumber.pbData ) ; if( certInfo.Issuer.pbData ) free( certInfo.Issuer.pbData ) ; - if( pCertContext != NULL ) { + if( pCertContext != nullptr ) { xcert = MswcryCertContextToXCert( pCertContext ) ; if( pCertContext ) CertFreeCertificateContext( pCertContext ) ; } else { - xcert = NULL ; + xcert = nullptr ; } return xcert ; @@ -725,7 +725,7 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_MSCryptImpl::buildCer CERT_CHAIN_PARA chainPara ; enhKeyUsage.cUsageIdentifier = 0 ; - enhKeyUsage.rgpszUsageIdentifier = NULL ; + enhKeyUsage.rgpszUsageIdentifier = nullptr ; certUsage.dwType = USAGE_MATCH_TYPE_AND ; certUsage.Usage = enhKeyUsage ; chainPara.cbSize = sizeof( CERT_CHAIN_PARA ) ; @@ -736,20 +736,20 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_MSCryptImpl::buildCer throw RuntimeException() ; } - xcert = ( X509Certificate_MSCryptImpl* )xCertTunnel->getSomething( X509Certificate_MSCryptImpl::getUnoTunnelId() ) ; - if( xcert == NULL ) { + xcert = reinterpret_cast<X509Certificate_MSCryptImpl*>(xCertTunnel->getSomething( X509Certificate_MSCryptImpl::getUnoTunnelId() )); + if( xcert == nullptr ) { throw RuntimeException() ; } pCertContext = xcert->getMswcryCert() ; - pChainContext = NULL ; + pChainContext = nullptr ; BOOL bChain = FALSE; - if( pCertContext != NULL ) + if( pCertContext != nullptr ) { - HCERTSTORE hAdditionalStore = NULL; - HCERTSTORE hCollectionStore = NULL; + HCERTSTORE hAdditionalStore = nullptr; + HCERTSTORE hCollectionStore = nullptr; if (m_hCertStore && m_hKeyStore) { //Merge m_hCertStore and m_hKeyStore into one store. @@ -758,9 +758,9 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_MSCryptImpl::buildCer 0 , NULL , 0 , - NULL + nullptr ) ; - if (hCollectionStore != NULL) + if (hCollectionStore != nullptr) { CertAddStoreToCollection ( hCollectionStore , @@ -778,31 +778,31 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_MSCryptImpl::buildCer } //if the merge of both stores failed then we add only m_hCertStore - if (hAdditionalStore == NULL && m_hCertStore) + if (hAdditionalStore == nullptr && m_hCertStore) hAdditionalStore = m_hCertStore; - else if (hAdditionalStore == NULL && m_hKeyStore) + else if (hAdditionalStore == nullptr && m_hKeyStore) hAdditionalStore = m_hKeyStore; else - hAdditionalStore = NULL; + hAdditionalStore = nullptr; //CertGetCertificateChain searches by default in MY, CA, ROOT and TRUST bChain = CertGetCertificateChain( - NULL , + nullptr , pCertContext , - NULL , //use current system time + nullptr , //use current system time hAdditionalStore, &chainPara , CERT_CHAIN_REVOCATION_CHECK_CHAIN | CERT_CHAIN_TIMESTAMP_TIME , - NULL , + nullptr , &pChainContext); if (!bChain) - pChainContext = NULL; + pChainContext = nullptr; //Close the additional store CertCloseStore(hCollectionStore, CERT_CLOSE_STORE_CHECK_FLAG); } - if(bChain && pChainContext != NULL && pChainContext->cChain > 0 ) + if(bChain && pChainContext != nullptr && pChainContext->cChain > 0 ) { PCCERT_CONTEXT pCertInChain ; PCERT_SIMPLE_CHAIN pCertChain ; @@ -816,17 +816,17 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_MSCryptImpl::buildCer if( pCertChain->rgpElement[i] ) pCertInChain = pCertChain->rgpElement[i]->pCertContext ; else - pCertInChain = NULL ; + pCertInChain = nullptr ; - if( pCertInChain != NULL ) { + if( pCertInChain != nullptr ) { pCert = MswcryCertContextToXCert( pCertInChain ) ; - if( pCert != NULL ) + if( pCert != nullptr ) xCertChain[i] = pCert ; } } CertFreeCertificateChain( pChainContext ) ; - pChainContext = NULL ; + pChainContext = nullptr ; return xCertChain ; } @@ -844,7 +844,7 @@ Reference< XCertificate > SecurityEnvironment_MSCryptImpl::createCertificateFrom xcert = new X509Certificate_MSCryptImpl() ; xcert->setRawCert( rawCertificate ) ; } else { - xcert = NULL ; + xcert = nullptr ; } return xcert ; @@ -856,12 +856,12 @@ Reference< XCertificate > SecurityEnvironment_MSCryptImpl::createCertificateFrom OString oscert = OUStringToOString( asciiCertificate , RTL_TEXTENCODING_ASCII_US ) ; - chCert = xmlStrndup( ( const xmlChar* )oscert.getStr(), ( int )oscert.getLength() ) ; + chCert = xmlStrndup( reinterpret_cast<const xmlChar*>(oscert.getStr()), ( int )oscert.getLength() ) ; - certSize = xmlSecBase64Decode( chCert, ( xmlSecByte* )chCert, xmlStrlen( chCert ) ) ; + certSize = xmlSecBase64Decode( chCert, chCert, xmlStrlen( chCert ) ) ; Sequence< sal_Int8 > rawCert( certSize ) ; - for( unsigned int i = 0 ; i < certSize ; i ++ ) + for( xmlSecSize i = 0 ; i < certSize ; i ++ ) rawCert[i] = *( chCert + i ) ; xmlFree( chCert ) ; @@ -873,11 +873,11 @@ Reference< XCertificate > SecurityEnvironment_MSCryptImpl::createCertificateFrom HCERTSTORE getCertStoreForIntermediatCerts( const Sequence< Reference< css::security::XCertificate > >& seqCerts) { - HCERTSTORE store = NULL; + HCERTSTORE store = nullptr; store = CertOpenStore( - CERT_STORE_PROV_MEMORY, 0, NULL, 0, NULL); - if (store == NULL) - return NULL; + CERT_STORE_PROV_MEMORY, 0, NULL, 0, nullptr); + if (store == nullptr) + return nullptr; for (int i = 0; i < seqCerts.getLength(); i++) { @@ -885,10 +885,10 @@ HCERTSTORE getCertStoreForIntermediatCerts( Sequence<sal_Int8> data = seqCerts[i]->getEncoded(); PCCERT_CONTEXT cert = CertCreateCertificateContext( - X509_ASN_ENCODING, ( const BYTE* )&data[0], data.getLength()); + X509_ASN_ENCODING, reinterpret_cast<const BYTE*>(&data[0]), data.getLength()); //Adding the certificate creates a copy and not just increases the ref count //Therefore we free later the certificate that we now add - CertAddCertificateContextToStore(store, cert, CERT_STORE_ADD_ALWAYS, NULL); + CertAddCertificateContextToStore(store, cert, CERT_STORE_ADD_ALWAYS, nullptr); CertFreeCertificateContext(cert); } return store; @@ -904,9 +904,9 @@ sal_Int32 SecurityEnvironment_MSCryptImpl::verifyCertificate( throw( css::uno::SecurityException, css::uno::RuntimeException ) { sal_Int32 validity = 0; - PCCERT_CHAIN_CONTEXT pChainContext = NULL; - PCCERT_CONTEXT pCertContext = NULL; - const X509Certificate_MSCryptImpl* xcert = NULL; + PCCERT_CHAIN_CONTEXT pChainContext = nullptr; + PCCERT_CONTEXT pCertContext = nullptr; + const X509Certificate_MSCryptImpl* xcert = nullptr; Reference< XUnoTunnel > xCertTunnel( aCert, UNO_QUERY ) ; if( !xCertTunnel.is() ) { @@ -915,8 +915,8 @@ sal_Int32 SecurityEnvironment_MSCryptImpl::verifyCertificate( SAL_INFO("xmlsecurity.xmlsec", "Start verification of certificate: " << aCert->getSubjectName()); - xcert = ( X509Certificate_MSCryptImpl* )xCertTunnel->getSomething( X509Certificate_MSCryptImpl::getUnoTunnelId() ) ; - if( xcert == NULL ) { + xcert = reinterpret_cast<X509Certificate_MSCryptImpl*>(xCertTunnel->getSomething( X509Certificate_MSCryptImpl::getUnoTunnelId() )); + if( xcert == nullptr ) { throw RuntimeException() ; } @@ -929,17 +929,17 @@ sal_Int32 SecurityEnvironment_MSCryptImpl::verifyCertificate( //Prepare parameter for CertGetCertificateChain enhKeyUsage.cUsageIdentifier = 0 ; - enhKeyUsage.rgpszUsageIdentifier = NULL ; + enhKeyUsage.rgpszUsageIdentifier = nullptr ; certUsage.dwType = USAGE_MATCH_TYPE_AND ; certUsage.Usage = enhKeyUsage ; chainPara.cbSize = sizeof( CERT_CHAIN_PARA ) ; chainPara.RequestedUsage = certUsage ; - HCERTSTORE hCollectionStore = NULL; - HCERTSTORE hIntermediateCertsStore = NULL; + HCERTSTORE hCollectionStore = nullptr; + HCERTSTORE hIntermediateCertsStore = nullptr; BOOL bChain = FALSE; - if( pCertContext != NULL ) + if( pCertContext != nullptr ) { hIntermediateCertsStore = getCertStoreForIntermediatCerts(seqCerts); @@ -951,9 +951,9 @@ sal_Int32 SecurityEnvironment_MSCryptImpl::verifyCertificate( 0 , NULL , 0 , - NULL + nullptr ) ; - if (hCollectionStore != NULL) + if (hCollectionStore != nullptr) { CertAddStoreToCollection ( hCollectionStore , @@ -978,13 +978,13 @@ sal_Int32 SecurityEnvironment_MSCryptImpl::verifyCertificate( //Then we would get CERT_TRUST_REVOCATION_STATUS_UNKNOWN SAL_INFO("xmlsecurity.xmlsec", "Verifying cert using revocation information."); bChain = CertGetCertificateChain( - NULL , + nullptr , pCertContext , - NULL , //use current system time + nullptr , //use current system time hCollectionStore, &chainPara , CERT_CHAIN_REVOCATION_CHECK_CHAIN | CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT, - NULL , + nullptr , &pChainContext); if (bChain && pChainContext->cChain > 0) @@ -1012,16 +1012,16 @@ sal_Int32 SecurityEnvironment_MSCryptImpl::verifyCertificate( //clear about if all other tests are performed if an error occurs, //we test again, without requiring revocation checking. CertFreeCertificateChain(pChainContext); - pChainContext = NULL; + pChainContext = nullptr; SAL_INFO("xmlsecurity.xmlsec", "Checking again but without requiring revocation information."); bChain = CertGetCertificateChain( - NULL , + nullptr , pCertContext , - NULL , //use current system time + nullptr , //use current system time hCollectionStore, &chainPara , 0, - NULL , + nullptr , &pChainContext); if (bChain && pChainContext->cChain > 0 @@ -1058,7 +1058,7 @@ sal_Int32 SecurityEnvironment_MSCryptImpl::verifyCertificate( if (pChainContext) { CertFreeCertificateChain(pChainContext); - pChainContext = NULL; + pChainContext = nullptr; } //Close the additional store, do not destroy the contained certs @@ -1080,8 +1080,8 @@ sal_Int32 SecurityEnvironment_MSCryptImpl::getCertificateCharacters( const css:: throw RuntimeException() ; } - xcert = ( X509Certificate_MSCryptImpl* )xCertTunnel->getSomething( X509Certificate_MSCryptImpl::getUnoTunnelId() ) ; - if( xcert == NULL ) { + xcert = reinterpret_cast<X509Certificate_MSCryptImpl*>(xCertTunnel->getSomething( X509Certificate_MSCryptImpl::getUnoTunnelId() )); + if( xcert == nullptr ) { throw RuntimeException() ; } @@ -1103,7 +1103,7 @@ sal_Int32 SecurityEnvironment_MSCryptImpl::getCertificateCharacters( const css:: HCRYPTPROV hProv ; if( CryptAcquireCertificatePrivateKey( pCertContext , 0 , - NULL , + nullptr , &( hProv ) , &( dwKeySpec ) , &( fCallerFreeProv ) ) @@ -1119,11 +1119,11 @@ sal_Int32 SecurityEnvironment_MSCryptImpl::getCertificateCharacters( const css:: return characters ; } -void SecurityEnvironment_MSCryptImpl::enableDefaultCrypt( sal_Bool enable ) throw( Exception, RuntimeException ) { +void SecurityEnvironment_MSCryptImpl::enableDefaultCrypt( bool enable ) throw( Exception, RuntimeException ) { m_bEnableDefault = enable ; } -sal_Bool SecurityEnvironment_MSCryptImpl::defaultEnabled() throw( Exception, RuntimeException ) { +bool SecurityEnvironment_MSCryptImpl::defaultEnabled() throw( Exception, RuntimeException ) { return m_bEnableDefault ; } @@ -1131,11 +1131,11 @@ X509Certificate_MSCryptImpl* MswcryCertContextToXCert( PCCERT_CONTEXT cert ) { X509Certificate_MSCryptImpl* xcert ; - if( cert != NULL ) { + if( cert != nullptr ) { xcert = new X509Certificate_MSCryptImpl() ; xcert->setMswcryCert( cert ) ; } else { - xcert = NULL ; + xcert = nullptr ; } return xcert ; @@ -1153,13 +1153,13 @@ xmlSecKeysMngrPtr SecurityEnvironment_MSCryptImpl::createKeysManager() throw( Ex HCRYPTKEY symKey ; HCRYPTKEY pubKey ; HCRYPTKEY priKey ; - xmlSecKeysMngrPtr pKeysMngr = NULL ; + xmlSecKeysMngrPtr pKeysMngr = nullptr ; /*- * The following lines is based on the of xmlsec-mscrypto crypto engine */ pKeysMngr = xmlSecMSCryptoAppliedKeysMngrCreate( m_hKeyStore , m_hCertStore ) ; - if( pKeysMngr == NULL ) + if( pKeysMngr == nullptr ) throw RuntimeException() ; /*- @@ -1195,40 +1195,40 @@ xmlSecKeysMngrPtr SecurityEnvironment_MSCryptImpl::createKeysManager() throw( Ex if( defaultEnabled() ) { //Add system key store into the keys manager. m_hMySystemStore = CertOpenSystemStore( 0, "MY" ) ; - if( m_hMySystemStore != NULL ) { + if( m_hMySystemStore != nullptr ) { if( xmlSecMSCryptoAppliedKeysMngrAdoptKeyStore( pKeysMngr, m_hMySystemStore ) < 0 ) { CertCloseStore( m_hMySystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; - m_hMySystemStore = NULL; + m_hMySystemStore = nullptr; throw RuntimeException() ; } } //Add system root store into the keys manager. m_hRootSystemStore = CertOpenSystemStore( 0, "Root" ) ; - if( m_hRootSystemStore != NULL ) { + if( m_hRootSystemStore != nullptr ) { if( xmlSecMSCryptoAppliedKeysMngrAdoptTrustedStore( pKeysMngr, m_hRootSystemStore ) < 0 ) { CertCloseStore( m_hRootSystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; - m_hRootSystemStore = NULL; + m_hRootSystemStore = nullptr; throw RuntimeException() ; } } //Add system trusted store into the keys manager. m_hTrustSystemStore = CertOpenSystemStore( 0, "Trust" ) ; - if( m_hTrustSystemStore != NULL ) { + if( m_hTrustSystemStore != nullptr ) { if( xmlSecMSCryptoAppliedKeysMngrAdoptUntrustedStore( pKeysMngr, m_hTrustSystemStore ) < 0 ) { CertCloseStore( m_hTrustSystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; - m_hTrustSystemStore = NULL; + m_hTrustSystemStore = nullptr; throw RuntimeException() ; } } //Add system CA store into the keys manager. m_hCaSystemStore = CertOpenSystemStore( 0, "CA" ) ; - if( m_hCaSystemStore != NULL ) { + if( m_hCaSystemStore != nullptr ) { if( xmlSecMSCryptoAppliedKeysMngrAdoptUntrustedStore( pKeysMngr, m_hCaSystemStore ) < 0 ) { CertCloseStore( m_hCaSystemStore, CERT_CLOSE_STORE_CHECK_FLAG ) ; - m_hCaSystemStore = NULL; + m_hCaSystemStore = nullptr; throw RuntimeException() ; } } @@ -1237,7 +1237,7 @@ xmlSecKeysMngrPtr SecurityEnvironment_MSCryptImpl::createKeysManager() throw( Ex return pKeysMngr ; } void SecurityEnvironment_MSCryptImpl::destroyKeysManager(xmlSecKeysMngrPtr pKeysMngr) throw( Exception, RuntimeException ) { - if( pKeysMngr != NULL ) { + if( pKeysMngr != nullptr ) { xmlSecKeysMngrDestroy( pKeysMngr ) ; } } diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.hxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.hxx index 62df6b7..e345c1e 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.hxx +++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.hxx @@ -73,7 +73,7 @@ class SecurityEnvironment_MSCryptImpl : public ::cppu::WeakImplHelper< HCERTSTORE m_hCaSystemStore; //Enable default system cryptography setting - sal_Bool m_bEnableDefault ; + bool m_bEnableDefault ; //External keys std::list< HCRYPTKEY > m_tSymKeyList ; @@ -85,16 +85,16 @@ class SecurityEnvironment_MSCryptImpl : public ::cppu::WeakImplHelper< public: explicit SecurityEnvironment_MSCryptImpl( const css::uno::Reference< css::lang::XMultiServiceFactory >& aFactory ) ; - virtual ~SecurityEnvironment_MSCryptImpl() ; + virtual ~SecurityEnvironment_MSCryptImpl() override; //Methods from XSecurityEnvironment virtual css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > SAL_CALL getPersonalCertificates() - throw( css::uno::SecurityException , css::uno::RuntimeException ) ; + throw( css::uno::SecurityException , css::uno::RuntimeException ) override; virtual css::uno::Reference< css::security::XCertificate > SAL_CALL getCertificate( const OUString& issuerName, const css::uno::Sequence< sal_Int8 >& serialNumber ) - throw( css::uno::SecurityException , css::uno::RuntimeException ) ; + throw( css::uno::SecurityException , css::uno::RuntimeException ) override; virtual css::uno::Reference< css::security::XCertificate > SAL_CALL getCertificate( const OUString& issuerName, @@ -103,38 +103,38 @@ class SecurityEnvironment_MSCryptImpl : public ::cppu::WeakImplHelper< virtual css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > SAL_CALL buildCertificatePath( const css::uno::Reference< css::security::XCertificate >& beginCert ) - throw( css::uno::SecurityException , css::uno::RuntimeException ) ; + throw( css::uno::SecurityException , css::uno::RuntimeException ) override; virtual css::uno::Reference< css::security::XCertificate > SAL_CALL createCertificateFromRaw( const css::uno::Sequence< sal_Int8 >& rawCertificate ) - throw( css::uno::SecurityException , css::uno::RuntimeException ) ; + throw( css::uno::SecurityException , css::uno::RuntimeException ) override; virtual css::uno::Reference< css::security::XCertificate > SAL_CALL createCertificateFromAscii( const OUString& asciiCertificate ) - throw( css::uno::SecurityException , css::uno::RuntimeException ) ; + throw( css::uno::SecurityException , css::uno::RuntimeException ) override; virtual ::sal_Int32 SAL_CALL verifyCertificate( const css::uno::Reference< css::security::XCertificate >& xCert, const css::uno::Sequence< css::uno::Reference< css::security::XCertificate > >& intermediateCertificates) - throw (css::uno::SecurityException, css::uno::RuntimeException) ; + throw (css::uno::SecurityException, css::uno::RuntimeException) override; virtual ::sal_Int32 SAL_CALL getCertificateCharacters( const css::uno::Reference< css::security::XCertificate >& xCert ) - throw (css::uno::SecurityException, css::uno::RuntimeException) ; + throw (css::uno::SecurityException, css::uno::RuntimeException) override; virtual OUString SAL_CALL getSecurityEnvironmentInformation( ) - throw (css::uno::RuntimeException); + throw (css::uno::RuntimeException) override; //Methods from XServiceInfo - virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException ) ; + virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException ) override; virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName - ) throw( css::uno::RuntimeException ) ; + ) throw( css::uno::RuntimeException ) override; - virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException ) ; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException ) override; //Helper for XServiceInfo static css::uno::Sequence< OUString > impl_getSupportedServiceNames() ; @@ -151,7 +151,7 @@ class SecurityEnvironment_MSCryptImpl : public ::cppu::WeakImplHelper< //Methods from XUnoTunnel virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) - throw (css::uno::RuntimeException); + throw (css::uno::RuntimeException) override; static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId() ; static SecurityEnvironment_MSCryptImpl* getImplementation( const css::uno::Reference< css::uno::XInterface >& rObj ) ; @@ -176,8 +176,8 @@ class SecurityEnvironment_MSCryptImpl : public ::cppu::WeakImplHelper< virtual HCRYPTKEY getPriKey( unsigned int position ) throw( css::uno::Exception , css::uno::RuntimeException ) ; - virtual void enableDefaultCrypt( sal_Bool enable ) throw( css::uno::Exception , css::uno::RuntimeException ) ; - virtual sal_Bool defaultEnabled() throw( css::uno::Exception , css::uno::RuntimeException ) ; + virtual void enableDefaultCrypt( bool enable ) throw( css::uno::Exception , css::uno::RuntimeException ) ; + virtual bool defaultEnabled() throw( css::uno::Exception , css::uno::RuntimeException ) ; //Native methods virtual xmlSecKeysMngrPtr createKeysManager() throw( css::uno::Exception , css::uno::RuntimeException ) ; diff --git a/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx index f0c262b..91158dd 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx @@ -58,15 +58,15 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL OString sCertDir(sCertDB.getStr(), sCertDB.getLength(), RTL_TEXTENCODING_ASCII_US); n_pCertStore = sCertDir.getStr(); n_hStoreHandle = CertOpenSystemStore( NULL, n_pCertStore ) ; - if( n_hStoreHandle == NULL ) + if( n_hStoreHandle == nullptr ) { - return NULL; + return nullptr; } } else { - n_pCertStore = NULL ; - n_hStoreHandle = NULL ; + n_pCertStore = nullptr ; + n_hStoreHandle = nullptr ; } xmlSecMSCryptoAppInit( n_pCertStore ) ; @@ -77,26 +77,26 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL /* Setup key slot and certDb */ cssu::Reference< cssl::XUnoTunnel > xSecEnvTunnel( xSecEnv, cssu::UNO_QUERY_THROW ); - SecurityEnvironment_MSCryptImpl* pSecEnv = ( SecurityEnvironment_MSCryptImpl* )xSecEnvTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ) ; - if( pSecEnv == NULL ) + SecurityEnvironment_MSCryptImpl* pSecEnv = reinterpret_cast<SecurityEnvironment_MSCryptImpl*>(xSecEnvTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() )); + if( pSecEnv == nullptr ) { - if( n_hStoreHandle != NULL ) + if( n_hStoreHandle != nullptr ) { CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ; } xmlSecMSCryptoAppShutdown() ; - return NULL; + return nullptr; } - if( n_hStoreHandle != NULL ) + if( n_hStoreHandle != nullptr ) { pSecEnv->setCryptoSlot( n_hStoreHandle ) ; pSecEnv->setCertDb( n_hStoreHandle ) ; } else { - pSecEnv->enableDefaultCrypt( sal_True ) ; + pSecEnv->enableDefaultCrypt( true ) ; } /* Build XML Security Context */ @@ -107,13 +107,13 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL } catch( cssu::Exception& ) { - if( n_hStoreHandle != NULL ) + if( n_hStoreHandle != nullptr ) { CertCloseStore( n_hStoreHandle, CERT_CLOSE_STORE_FORCE_FLAG ) ; } xmlSecMSCryptoAppShutdown() ; - return NULL; + return nullptr; } } @@ -163,7 +163,7 @@ cssu::Sequence< OUString > SAL_CALL SEInitializer_MSCryptImpl_getSupportedServic cssu::Reference< cssu::XInterface > SAL_CALL SEInitializer_MSCryptImpl_createInstance( const cssu::Reference< cssl::XMultiServiceFactory > & rSMgr) throw( cssu::Exception ) { - return (cppu::OWeakObject*) new SEInitializer_MSCryptImpl( comphelper::getComponentContext(rSMgr) ); + return static_cast<cppu::OWeakObject*>(new SEInitializer_MSCryptImpl( comphelper::getComponentContext(rSMgr) )); } /* XServiceInfo */ diff --git a/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.hxx b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.hxx index 1ffd04f..46c698c 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.hxx +++ b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.hxx @@ -52,32 +52,32 @@ private: public: explicit SEInitializer_MSCryptImpl(const css::uno::Reference< css::uno::XComponentContext > &rxContext); - virtual ~SEInitializer_MSCryptImpl(); + virtual ~SEInitializer_MSCryptImpl() override; /* XSEInitializer */ virtual css::uno::Reference< css::xml::crypto::XXMLSecurityContext > SAL_CALL createSecurityContext( const OUString& certDB ) - throw (css::uno::RuntimeException); + throw (css::uno::RuntimeException) override; virtual void SAL_CALL freeSecurityContext( const css::uno::Reference< css::xml::crypto::XXMLSecurityContext >& securityContext ) - throw (css::uno::RuntimeException); + throw (css::uno::RuntimeException) override; /* XServiceInfo */ virtual OUString SAL_CALL getImplementationName( ) - throw (css::uno::RuntimeException); + throw (css::uno::RuntimeException) override; virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) - throw (css::uno::RuntimeException); + throw (css::uno::RuntimeException) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) - throw (css::uno::RuntimeException); + throw (css::uno::RuntimeException) override; }; OUString SEInitializer_MSCryptImpl_getImplementationName() throw ( css::uno::RuntimeException ); -sal_Bool SAL_CALL SEInitializer_MSCryptImpl_supportsService( const OUString& ServiceName ) +bool SAL_CALL SEInitializer_MSCryptImpl_supportsService( const OUString& ServiceName ) throw ( css::uno::RuntimeException ); css::uno::Sequence< OUString > SAL_CALL SEInitializer_MSCryptImpl_getSupportedServiceNames( ) diff --git a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx index 109fec4..c203302 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx @@ -157,7 +157,7 @@ findTypeInDN(const OUString& rRawString, const OUString& sTypeName) strings for type names. Instead it uses OIDs. */ -OUString replaceTagSWithTagST(OUString oldDN) +OUString replaceTagSWithTagST(OUString const & oldDN) { std::pair<sal_Int32, sal_Int32 > pairIndex = findTypeInDN(oldDN, "S"); @@ -170,19 +170,19 @@ OUString replaceTagSWithTagST(OUString oldDN) /* end */ X509Certificate_MSCryptImpl::X509Certificate_MSCryptImpl() : - m_pCertContext( NULL ) + m_pCertContext( nullptr ) { } X509Certificate_MSCryptImpl::~X509Certificate_MSCryptImpl() { - if( m_pCertContext != NULL ) { + if( m_pCertContext != nullptr ) { CertFreeCertificateContext( m_pCertContext ) ; } } //Methods from XCertificate sal_Int16 SAL_CALL X509Certificate_MSCryptImpl::getVersion() throw ( css::uno::RuntimeException) { - if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) { + if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr ) { return ( char )m_pCertContext->pCertInfo->dwVersion ; } else { return -1 ; @@ -190,7 +190,7 @@ sal_Int16 SAL_CALL X509Certificate_MSCryptImpl::getVersion() throw ( css::uno::R } css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getSerialNumber() throw ( css::uno::RuntimeException) { - if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) { + if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr ) { Sequence< sal_Int8 > serial( m_pCertContext->pCertInfo->SerialNumber.cbData ) ; for( unsigned int i = 0 ; i < m_pCertContext->pCertInfo->SerialNumber.cbData ; i ++ ) serial[i] = *( m_pCertContext->pCertInfo->SerialNumber.pbData + m_pCertContext->pCertInfo->SerialNumber.cbData - i - 1 ) ; @@ -202,14 +202,14 @@ css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getSerialNu } OUString SAL_CALL X509Certificate_MSCryptImpl::getIssuerName() throw ( css::uno::RuntimeException) { - if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) { + if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr ) { DWORD cbIssuer ; cbIssuer = CertNameToStr( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , &( m_pCertContext->pCertInfo->Issuer ), CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG , - NULL, 0 + nullptr, 0 ) ; // Here the cbIssuer count the last 0x00 , take care. @@ -230,7 +230,7 @@ OUString SAL_CALL X509Certificate_MSCryptImpl::getIssuerName() throw ( css::uno: // for correct encoding sal_uInt16 encoding ; - rtl_Locale *pLocale = NULL ; + rtl_Locale *pLocale = nullptr ; osl_getProcessLocale( &pLocale ) ; encoding = osl_getTextEncodingFromLocale( pLocale ) ; @@ -249,7 +249,7 @@ OUString SAL_CALL X509Certificate_MSCryptImpl::getIssuerName() throw ( css::uno: OUString SAL_CALL X509Certificate_MSCryptImpl::getSubjectName() throw ( css::uno::RuntimeException) { - if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) + if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr ) { DWORD cbSubject ; @@ -257,7 +257,7 @@ OUString SAL_CALL X509Certificate_MSCryptImpl::getSubjectName() throw ( css::uno X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , &( m_pCertContext->pCertInfo->Subject ), CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG , - NULL, 0 + nullptr, 0 ) ; if( cbSubject != 0 ) @@ -292,7 +292,7 @@ OUString SAL_CALL X509Certificate_MSCryptImpl::getSubjectName() throw ( css::uno } css::util::DateTime SAL_CALL X509Certificate_MSCryptImpl::getNotValidBefore() throw ( css::uno::RuntimeException ) { - if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) { + if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr ) { SYSTEMTIME explTime ; DateTime dateTime ; FILETIME localFileTime; @@ -318,7 +318,7 @@ css::util::DateTime SAL_CALL X509Certificate_MSCryptImpl::getNotValidBefore() th } css::util::DateTime SAL_CALL X509Certificate_MSCryptImpl::getNotValidAfter() throw ( css::uno::RuntimeException) { - if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) { + if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr ) { SYSTEMTIME explTime ; DateTime dateTime ; FILETIME localFileTime; @@ -344,7 +344,7 @@ css::util::DateTime SAL_CALL X509Certificate_MSCryptImpl::getNotValidAfter() thr } css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getIssuerUniqueID() throw ( css::uno::RuntimeException) { - if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) { + if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr ) { Sequence< sal_Int8 > issuerUid( m_pCertContext->pCertInfo->IssuerUniqueId.cbData ) ; for( unsigned int i = 0 ; i < m_pCertContext->pCertInfo->IssuerUniqueId.cbData; i ++ ) issuerUid[i] = *( m_pCertContext->pCertInfo->IssuerUniqueId.pbData + i ) ; @@ -356,7 +356,7 @@ css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getIssuerUn } css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getSubjectUniqueID() throw ( css::uno::RuntimeException ) { - if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) { + if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr ) { Sequence< sal_Int8 > subjectUid( m_pCertContext->pCertInfo->SubjectUniqueId.cbData ) ; for( unsigned int i = 0 ; i < m_pCertContext->pCertInfo->SubjectUniqueId.cbData; i ++ ) subjectUid[i] = *( m_pCertContext->pCertInfo->SubjectUniqueId.pbData + i ) ; @@ -368,7 +368,7 @@ css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getSubjectU } css::uno::Sequence< css::uno::Reference< css::security::XCertificateExtension > > SAL_CALL X509Certificate_MSCryptImpl::getExtensions() throw ( css::uno::RuntimeException ) { - if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL && m_pCertContext->pCertInfo->cExtension != 0 ) { + if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr && m_pCertContext->pCertInfo->cExtension != 0 ) { CertificateExtension_XmlSecImpl* xExtn ; Sequence< Reference< XCertificateExtension > > xExtns( m_pCertContext->pCertInfo->cExtension ) ; @@ -379,13 +379,13 @@ css::uno::Sequence< css::uno::Reference< css::security::XCertificateExtension > OUString objId = OUString::createFromAscii( pExtn->pszObjId ); if ( objId == "2.5.29.17" ) - xExtn = (CertificateExtension_XmlSecImpl*) new SanExtensionImpl() ; + xExtn = reinterpret_cast<CertificateExtension_XmlSecImpl*>(new SanExtensionImpl()); else xExtn = new CertificateExtension_XmlSecImpl() ; - if( xExtn == NULL ) + if( xExtn == nullptr ) throw RuntimeException() ; - xExtn->setCertExtn( pExtn->Value.pbData, pExtn->Value.cbData, ( unsigned char* )pExtn->pszObjId, strlen( pExtn->pszObjId ), pExtn->fCritical ) ; + xExtn->setCertExtn( pExtn->Value.pbData, pExtn->Value.cbData, reinterpret_cast<unsigned char*>(pExtn->pszObjId), strlen( pExtn->pszObjId ), pExtn->fCritical ) ; xExtns[i] = xExtn ; } @@ -397,32 +397,32 @@ css::uno::Sequence< css::uno::Reference< css::security::XCertificateExtension > } css::uno::Reference< css::security::XCertificateExtension > SAL_CALL X509Certificate_MSCryptImpl::findCertificateExtension( const css::uno::Sequence< sal_Int8 >& /*oid*/ ) throw (css::uno::RuntimeException) { - if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL && m_pCertContext->pCertInfo->cExtension != 0 ) { + if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr && m_pCertContext->pCertInfo->cExtension != 0 ) { CertificateExtension_XmlSecImpl* xExtn ; - xExtn = NULL ; + xExtn = nullptr ; for( unsigned int i = 0; i < m_pCertContext->pCertInfo->cExtension; i++ ) { CERT_EXTENSION* pExtn = &( m_pCertContext->pCertInfo->rgExtension[i] ) ; //TODO: Compare the oid - if( 0 ) { + if( false ) { xExtn = new CertificateExtension_XmlSecImpl() ; - if( xExtn == NULL ) + if( xExtn == nullptr ) throw RuntimeException() ; - xExtn->setCertExtn( pExtn->Value.pbData, pExtn->Value.cbData, ( unsigned char* )pExtn->pszObjId, strlen( pExtn->pszObjId ), pExtn->fCritical ) ; + xExtn->setCertExtn( pExtn->Value.pbData, pExtn->Value.cbData, reinterpret_cast<unsigned char*>(pExtn->pszObjId), strlen( pExtn->pszObjId ), pExtn->fCritical ) ; } } return xExtn ; } else { - return NULL ; + return nullptr ; } } css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getEncoded() throw ( css::uno::RuntimeException) { - if( m_pCertContext != NULL && m_pCertContext->cbCertEncoded > 0 ) { + if( m_pCertContext != nullptr && m_pCertContext->cbCertEncoded > 0 ) { Sequence< sal_Int8 > rawCert( m_pCertContext->cbCertEncoded ) ; for( unsigned int i = 0 ; i < m_pCertContext->cbCertEncoded ; i ++ ) @@ -436,39 +436,39 @@ css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getEncoded( //Helper methods void X509Certificate_MSCryptImpl::setMswcryCert( const CERT_CONTEXT* cert ) { - if( m_pCertContext != NULL ) { + if( m_pCertContext != nullptr ) { CertFreeCertificateContext( m_pCertContext ) ; - m_pCertContext = NULL ; + m_pCertContext = nullptr ; } - if( cert != NULL ) { + if( cert != nullptr ) { m_pCertContext = CertDuplicateCertificateContext( cert ) ; } } const CERT_CONTEXT* X509Certificate_MSCryptImpl::getMswcryCert() const { - if( m_pCertContext != NULL ) { + if( m_pCertContext != nullptr ) { return m_pCertContext ; } else { - return NULL ; + return nullptr ; } } -void X509Certificate_MSCryptImpl::setRawCert( Sequence< sal_Int8 > rawCert ) throw ( css::uno::RuntimeException) { - if( m_pCertContext != NULL ) { +void X509Certificate_MSCryptImpl::setRawCert( Sequence< sal_Int8 > const & rawCert ) throw ( css::uno::RuntimeException) { + if( m_pCertContext != nullptr ) { CertFreeCertificateContext( m_pCertContext ) ; - m_pCertContext = NULL ; + m_pCertContext = nullptr ; } if( rawCert.getLength() != 0 ) { - m_pCertContext = CertCreateCertificateContext( X509_ASN_ENCODING, ( const sal_uInt8* )&rawCert[0], rawCert.getLength() ) ; + m_pCertContext = CertCreateCertificateContext( X509_ASN_ENCODING, reinterpret_cast<const sal_uInt8*>(&rawCert[0]), rawCert.getLength() ) ; } } /* XUnoTunnel */ sal_Int64 SAL_CALL X509Certificate_MSCryptImpl::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw( RuntimeException ) { if( aIdentifier.getLength() == 16 && 0 == memcmp( getUnoTunnelId().getConstArray(), aIdentifier.getConstArray(), 16 ) ) { - return ( sal_Int64 )this ; + return reinterpret_cast<sal_Int64>(this); } return 0 ; } @@ -488,9 +488,9 @@ const Sequence< sal_Int8>& X509Certificate_MSCryptImpl::getUnoTunnelId() { X509Certificate_MSCryptImpl* X509Certificate_MSCryptImpl::getImplementation( const Reference< XInterface >& rObj ) { Reference< XUnoTunnel > xUT( rObj , UNO_QUERY ) ; if( xUT.is() ) { - return ( X509Certificate_MSCryptImpl* )xUT->getSomething( getUnoTunnelId() ) ; + return reinterpret_cast<X509Certificate_MSCryptImpl*>(xUT->getSomething( getUnoTunnelId() )); } else - return NULL ; + return nullptr ; } OUString findOIDDescription(char *oid) @@ -510,11 +510,11 @@ OUString findOIDDescription(char *oid) css::uno::Sequence< sal_Int8 > getThumbprint(const CERT_CONTEXT* pCertContext, DWORD dwPropId) { - if( pCertContext != NULL ) + if( pCertContext != nullptr ) { DWORD cbData = dwPropId == CERT_SHA256_HASH_PROP_ID ? 32 : 20; unsigned char fingerprint[32]; - if (CertGetCertificateContextProperty(pCertContext, dwPropId, (void*)fingerprint, &cbData)) + if (CertGetCertificateContextProperty(pCertContext, dwPropId, fingerprint, &cbData)) { Sequence< sal_Int8 > thumbprint( cbData ) ; for( unsigned int i = 0 ; i < cbData ; i ++ ) @@ -537,7 +537,7 @@ css::uno::Sequence< sal_Int8 > getThumbprint(const CERT_CONTEXT* pCertContext, D OUString SAL_CALL X509Certificate_MSCryptImpl::getSubjectPublicKeyAlgorithm() throw ( css::uno::RuntimeException) { - if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) + if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr ) { CRYPT_ALGORITHM_IDENTIFIER algorithm = m_pCertContext->pCertInfo->SubjectPublicKeyInfo.Algorithm; return findOIDDescription( algorithm.pszObjId ) ; @@ -551,7 +551,7 @@ OUString SAL_CALL X509Certificate_MSCryptImpl::getSubjectPublicKeyAlgorithm() css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getSubjectPublicKeyValue() throw ( css::uno::RuntimeException) { - if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) + if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr ) { CRYPT_BIT_BLOB publicKey = m_pCertContext->pCertInfo->SubjectPublicKeyInfo.PublicKey; @@ -572,7 +572,7 @@ css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getSubjectP OUString SAL_CALL X509Certificate_MSCryptImpl::getSignatureAlgorithm() throw ( css::uno::RuntimeException) { - if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL ) + if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr ) { CRYPT_ALGORITHM_IDENTIFIER algorithm = m_pCertContext->pCertInfo->SignatureAlgorithm; return findOIDDescription( algorithm.pszObjId ) ; @@ -612,14 +612,14 @@ sal_Int32 SAL_CALL X509Certificate_MSCryptImpl::getCertificateUsage( ) CERT_NON_REPUDIATION_KEY_USAGE | CERT_OFFLINE_CRL_SIGN_KEY_USAGE; - if( m_pCertContext != NULL && m_pCertContext->pCertInfo != NULL && m_pCertContext->pCertInfo->cExtension != 0 ) + if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr && m_pCertContext->pCertInfo->cExtension != 0 ) { CERT_EXTENSION* pExtn = CertFindExtension( szOID_KEY_USAGE, m_pCertContext->pCertInfo->cExtension, m_pCertContext->pCertInfo->rgExtension); - if (pExtn != NULL) + if (pExtn != nullptr) { DWORD length = 0; bool rc = CryptDecodeObject( @@ -628,7 +628,7 @@ sal_Int32 SAL_CALL X509Certificate_MSCryptImpl::getCertificateUsage( ) pExtn->Value.pbData, pExtn->Value.cbData, 0, - NULL, + nullptr, &length); if (!rc) @@ -643,10 +643,10 @@ sal_Int32 SAL_CALL X509Certificate_MSCryptImpl::getCertificateUsage( ) pExtn->Value.pbData, pExtn->Value.cbData, 0, - (void *)buffer.data(), + buffer.data(), &length); - CRYPT_BIT_BLOB *blob = (CRYPT_BIT_BLOB*)buffer.data(); + CRYPT_BIT_BLOB *blob = reinterpret_cast<CRYPT_BIT_BLOB*>(buffer.data()); if (!rc) SAL_WARN("xmlsecurity.xmlsec", "CryptDecodeObject failed: " << WindowsErrorString(GetLastError())); else if (blob->cbData == 1) diff --git a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.hxx b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.hxx index 09fd6b38..54997cd 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.hxx +++ b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.hxx @@ -47,7 +47,7 @@ class X509Certificate_MSCryptImpl : public ::cppu::WeakImplHelper< public: X509Certificate_MSCryptImpl() ; - virtual ~X509Certificate_MSCryptImpl() ; + virtual ~X509Certificate_MSCryptImpl() override; //Methods from XCertificate virtual sal_Int16 SAL_CALL getVersion() throw ( css::uno::RuntimeException) override; @@ -87,7 +87,7 @@ class X509Certificate_MSCryptImpl : public ::cppu::WeakImplHelper< //Helper methods void setMswcryCert( const CERT_CONTEXT* cert ) ; const CERT_CONTEXT* getMswcryCert() const ; - void setRawCert( css::uno::Sequence< sal_Int8 > rawCert ) throw ( css::uno::RuntimeException) ; + void setRawCert( css::uno::Sequence< sal_Int8 > const & rawCert ) throw ( css::uno::RuntimeException) ; } ; #endif // INCLUDED_XMLSECURITY_SOURCE_XMLSEC_MSCRYPT_X509CERTIFICATE_MSCRYPTIMPL_HXX diff --git a/xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.cxx index 0ff4c0b..2e54951 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/xmlencryption_mscryptimpl.cxx @@ -61,10 +61,10 @@ SAL_CALL XMLEncryption_MSCryptImpl::encrypt( ) throw( css::xml::crypto::XMLEncryptionException, css::uno::SecurityException ) { - xmlSecKeysMngrPtr pMngr = NULL ; - xmlSecEncCtxPtr pEncCtx = NULL ; - xmlNodePtr pEncryptedData = NULL ; - xmlNodePtr pContent = NULL ; + xmlSecKeysMngrPtr pMngr = nullptr ; + xmlSecEncCtxPtr pEncCtx = nullptr ; + xmlNodePtr pEncryptedData = nullptr ; + xmlNodePtr pContent = nullptr ; if( !aTemplate.is() ) throw RuntimeException() ; @@ -78,8 +78,8 @@ SAL_CALL XMLEncryption_MSCryptImpl::encrypt( throw RuntimeException() ; } - SecurityEnvironment_MSCryptImpl* pSecEnv = ( SecurityEnvironment_MSCryptImpl* )xSecTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ) ; - if( pSecEnv == NULL ) + SecurityEnvironment_MSCryptImpl* pSecEnv = reinterpret_cast<SecurityEnvironment_MSCryptImpl*>(xSecTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() )); + if( pSecEnv == nullptr ) throw RuntimeException() ; //Get the encryption template @@ -93,8 +93,8 @@ SAL_CALL XMLEncryption_MSCryptImpl::encrypt( throw RuntimeException() ; } - XMLElementWrapper_XmlSecImpl* pTemplate = ( XMLElementWrapper_XmlSecImpl* )xTplTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() ) ; - if( pTemplate == NULL ) { + XMLElementWrapper_XmlSecImpl* pTemplate = reinterpret_cast<XMLElementWrapper_XmlSecImpl*>(xTplTunnel->getSomething( XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId() )); + if( pTemplate == nullptr ) { throw RuntimeException() ; } @@ -103,28 +103,28 @@ SAL_CALL XMLEncryption_MSCryptImpl::encrypt( //Find the element to be encrypted. //This element is wrapped in the CipherValue sub-element. xmlNodePtr pCipherData = pEncryptedData->children; - while (pCipherData != NULL && stricmp((const char *)(pCipherData->name), "CipherData")) + while (pCipherData != nullptr && stricmp(reinterpret_cast<const char *>(pCipherData->name), "CipherData")) { pCipherData = pCipherData->next; } - if( pCipherData == NULL ) { + if( pCipherData == nullptr ) { throw XMLEncryptionException() ; } xmlNodePtr pCipherValue = pCipherData->children; - while (pCipherValue != NULL && stricmp((const char *)(pCipherValue->name), "CipherValue")) + while (pCipherValue != nullptr && stricmp(reinterpret_cast<const char *>(pCipherValue->name), "CipherValue")) { pCipherValue = pCipherValue->next; } - if( pCipherValue == NULL ) { + if( pCipherValue == nullptr ) { throw XMLEncryptionException() ; } pContent = pCipherValue->children; - if( pContent == NULL ) { + if( pContent == nullptr ) { throw XMLEncryptionException() ; } @@ -132,7 +132,7 @@ SAL_CALL XMLEncryption_MSCryptImpl::encrypt( xmlAddNextSibling(pEncryptedData, pContent); //remember the position of the element to be signed - sal_Bool isParentRef = sal_True; + bool isParentRef = true; xmlNodePtr pParent = pEncryptedData->parent; xmlNodePtr referenceNode; @@ -143,7 +143,7 @@ SAL_CALL XMLEncryption_MSCryptImpl::encrypt( else { referenceNode = pEncryptedData->prev; - isParentRef = sal_False; + isParentRef = false; } setErrorRecorder( ); @@ -155,7 +155,7 @@ SAL_CALL XMLEncryption_MSCryptImpl::encrypt( //Create Encryption context pEncCtx = xmlSecEncCtxCreate( pMngr ) ; - if( pEncCtx == NULL ) + if( pEncCtx == nullptr ) { pSecEnv->destroyKeysManager( pMngr ); //throw XMLEncryptionException() ; @@ -196,9 +196,9 @@ XMLEncryption_MSCryptImpl::decrypt( const Reference< XXMLSecurityContext >& aSecurityCtx ) throw( css::xml::crypto::XMLEncryptionException , css::uno::SecurityException) { - xmlSecKeysMngrPtr pMngr = NULL ; - xmlSecEncCtxPtr pEncCtx = NULL ; - xmlNodePtr pEncryptedData = NULL ; + xmlSecKeysMngrPtr pMngr = nullptr ; + xmlSecEncCtxPtr pEncCtx = nullptr ; + xmlNodePtr pEncryptedData = nullptr ; if( !aTemplate.is() ) throw RuntimeException() ; @@ -215,8 +215,8 @@ XMLEncryption_MSCryptImpl::decrypt( throw RuntimeException() ; } ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
