summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorThorsten Behrens <Thorsten.Behrens@CIB.de>2017-06-24 00:17:04 +0200
committerKatarina Behrens <Katarina.Behrens@cib.de>2017-06-26 18:15:38 +0200
commitbe65302ae7d0c64362ea224253261a0fe0b5e9e3 (patch)
tree3923823ef28b2b1f8c448ae20d01dcb81045fa85 /xmlsecurity
parent68d7d974867d226aaf691f6609651fdcd30b7d36 (diff)
gpp4libre: error handling, proper key extraction
Change-Id: I1cb219f825393309219a4ebfb406482050b91228 Reviewed-on: https://gerrit.libreoffice.org/39191 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> (cherry picked from commit 879fea59a0bcc1a439e51ab0923e1cc41dff5bfb) Reviewed-on: https://gerrit.libreoffice.org/39230 Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx12
1 files changed, 10 insertions, 2 deletions
diff --git a/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx b/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx
index 40248ee3a9e8..c0f570d19968 100644
--- a/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx
+++ b/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx
@@ -178,7 +178,7 @@ SAL_CALL XMLSignature_GpgImpl::generate(
cur = xmlSecGetNextElementNode(cur->next);
cur = xmlSecGetNextElementNode(cur->children);
// check that this is now PGPData
- if(!xmlSecCheckNodeName(cur, xmlSecNamePGPData, xmlSecDSigNs))
+ if(!xmlSecCheckNodeName(cur, xmlSecNodePGPData, xmlSecDSigNs))
throw RuntimeException("The GpgME library failed to initialize for the OpenPGP protocol.");
// check that this is now PGPKeyID
cur = xmlSecGetNextElementNode(cur->children);
@@ -189,11 +189,16 @@ SAL_CALL XMLSignature_GpgImpl::generate(
GpgME::Context& rCtx=pSecEnv->getGpgContext();
rCtx.setKeyListMode(GPGME_KEYLIST_MODE_LOCAL);
GpgME::Error err;
+ xmlChar* pKey=xmlNodeGetContent(cur);
+ if(xmlSecBase64Decode(pKey, reinterpret_cast<xmlSecByte*>(pKey), xmlStrlen(pKey)) < 0)
+ throw RuntimeException("The GpgME library failed to initialize for the OpenPGP protocol.");
if( rCtx.addSigningKey(
rCtx.key(
- reinterpret_cast<char*>(xmlNodeGetContent(cur)), err, true)) )
+ reinterpret_cast<char*>(pKey), err, true)) )
throw RuntimeException("The GpgME library failed to initialize for the OpenPGP protocol.");
+ xmlFree(pKey);
+
// good, ctx is setup now, let's sign the lot
GpgME::Data data_in(
reinterpret_cast<char*>(xmlSecBufferGetData(pDsigCtx->transformCtx.result)),
@@ -209,6 +214,9 @@ SAL_CALL XMLSignature_GpgImpl::generate(
while( (curr=data_out.read(&buf, 1)) )
len += curr;
+ if(sign_res.error() || !len)
+ throw RuntimeException("The GpgME library failed to initialize for the OpenPGP protocol.");
+
// write signed data to xml
std::vector<unsigned char> buf2(len);
assert(data_out.seek(0,SEEK_SET) == 0);