# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1272382275 -10800 # Node ID d10d750052f05725f53426638a20031b6cb43894 # Parent 361f875fa818091261c998f185f1fb0950bd4ccd Revision: 201014 Kit: 201017 diff -r 361f875fa818 -r d10d750052f0 xmlsecurityengine/xmlsec/src/xmlsec_bn.c --- a/xmlsecurityengine/xmlsec/src/xmlsec_bn.c Thu Apr 01 00:31:02 2010 +0300 +++ b/xmlsecurityengine/xmlsec/src/xmlsec_bn.c Tue Apr 27 18:31:15 2010 +0300 @@ -263,7 +263,7 @@ continue; } - xmlSecAssert2(ch <= sizeof(xmlSecBnLookupTable), -1); + xmlSecAssert2(ch <(sizeof(xmlSecBnLookupTable)/sizeof(xmlSecBnLookupTable[0])), -1); nn = xmlSecBnLookupTable[ch]; if((nn < 0) || ((xmlSecSize)nn > base)) { xmlSecError(XMLSEC_ERRORS_HERE, @@ -426,9 +426,10 @@ return (NULL); } memset(res, 0, len + 1); - - for(i = 0; (xmlSecBufferGetSize(&bn2) > 0) && (i < len); i++) { - if(xmlSecBnDiv(&bn2, base, &nn) < 0) { + for(i = 0; (xmlSecBufferGetSize(&bn2) > 0) && (i < len); i++) + { + if(xmlSecBnDiv(&bn2, base, &nn) < 0) + { xmlSecError(XMLSEC_ERRORS_HERE, NULL, "xmlSecBnDiv", @@ -437,11 +438,19 @@ xmlFree(res); xmlSecBnFinalize(&bn2); return (NULL); - } - xmlSecAssert2((size_t)nn < sizeof(xmlSecBnRevLookupTable), NULL); + } + if(nn >=(sizeof(xmlSecBnRevLookupTable)/sizeof(xmlSecBnRevLookupTable[0]))) + { + xmlFree(res); + return (NULL); + } res[i] = xmlSecBnRevLookupTable[nn]; - } - xmlSecAssert2(i < len, NULL); + } + if(i >=len) + { + xmlFree(res); + return (NULL); + } /* we might have '0' at the beggining, remove it but keep one zero */ for(len = i; (len > 1) && (res[len - 1] == '0'); len--) diff -r 361f875fa818 -r d10d750052f0 xmlsecurityengine/xmlsec/src/xmlsec_errors.c --- a/xmlsecurityengine/xmlsec/src/xmlsec_errors.c Thu Apr 01 00:31:02 2010 +0300 +++ b/xmlsecurityengine/xmlsec/src/xmlsec_errors.c Tue Apr 27 18:31:15 2010 +0300 @@ -242,8 +242,9 @@ if(msg != NULL) { va_list va; - - va_start(va, msg); + + //va points to the first argument in the list of variable arguments + va_start(va, msg); xmlSecStrVPrintf(error_msg, sizeof(error_msg), BAD_CAST msg, va); error_msg[sizeof(error_msg) - 1] = '\0'; va_end(va); diff -r 361f875fa818 -r d10d750052f0 xmlsecurityengine/xmlsec/src/xmlsec_keyinfo.c --- a/xmlsecurityengine/xmlsec/src/xmlsec_keyinfo.c Thu Apr 01 00:31:02 2010 +0300 +++ b/xmlsecurityengine/xmlsec/src/xmlsec_keyinfo.c Tue Apr 27 18:31:15 2010 +0300 @@ -770,9 +770,14 @@ } /* finally set key name if it is not there */ - if(xmlSecKeyGetName(key) == NULL) { - xmlSecKeySetName(key, newName); - } + if(xmlSecKeyGetName(key) == NULL) + { + if(xmlSecKeySetName(key, newName)<0) + { + xmlFree(newName); + return(-1); + } + } xmlFree(newName); return(0); } diff -r 361f875fa818 -r d10d750052f0 xmlsecurityengine/xmlsec/src/xmlsec_keys.c --- a/xmlsecurityengine/xmlsec/src/xmlsec_keys.c Thu Apr 01 00:31:02 2010 +0300 +++ b/xmlsecurityengine/xmlsec/src/xmlsec_keys.c Tue Apr 27 18:31:15 2010 +0300 @@ -169,25 +169,28 @@ xmlSecAssert2(keyUseWith != NULL, NULL); newKeyUseWith = xmlSecKeyUseWithCreate(NULL, NULL); - if(newKeyUseWith == NULL) { - xmlSecError(XMLSEC_ERRORS_HERE, + if(newKeyUseWith == NULL) + { + xmlSecError(XMLSEC_ERRORS_HERE, NULL, "xmlSecKeyUseWithCreate", XMLSEC_ERRORS_R_XMLSEC_FAILED, XMLSEC_ERRORS_NO_MESSAGE); return(NULL); - } + } ret = xmlSecKeyUseWithCopy(newKeyUseWith, keyUseWith); - if(ret < 0) { + if(ret < 0) + { xmlSecError(XMLSEC_ERRORS_HERE, NULL, "xmlSecKeyUseWithCopy", XMLSEC_ERRORS_R_XMLSEC_FAILED, XMLSEC_ERRORS_NO_MESSAGE); - xmlSecKeyUseWithDestroy(keyUseWith); + xmlSecKeyUseWithDestroy(keyUseWith); + xmlSecKeyUseWithDestroy( newKeyUseWith); return(NULL); - } + } return(newKeyUseWith); } @@ -1384,8 +1387,9 @@ if(keyInfoNode != NULL) { ret = xmlSecKeyInfoNodeRead(keyInfoNode, key, keyInfoCtx); - if(ret < 0) { - xmlSecError(XMLSEC_ERRORS_HERE, + if(ret < 0) + { + xmlSecError(XMLSEC_ERRORS_HERE, NULL, "xmlSecKeyInfoNodeRead", XMLSEC_ERRORS_R_XMLSEC_FAILED, @@ -1403,39 +1407,45 @@ tempkey=xmlSecKeyDuplicate(key); if(tempkey == NULL) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - "xmlSecKeysMngrFindKey", - XMLSEC_ERRORS_R_XMLSEC_FAILED, - XMLSEC_ERRORS_NO_MESSAGE); - return(NULL); + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, + "xmlSecKeysMngrFindKey", + XMLSEC_ERRORS_R_XMLSEC_FAILED, + XMLSEC_ERRORS_NO_MESSAGE); + xmlSecKeyDestroy(key); + return(NULL); } - keyname=xmlSecKeyGetName(tempkey); + keyname=xmlSecKeyGetName(tempkey); xmlSecKeyDestroy(key); /* if we have keys manager, try it */ - if(keyInfoCtx->keysMngr != NULL) { - key = xmlSecKeysMngrFindKey(keyInfoCtx->keysMngr, keyname /*NULL*/, keyInfoCtx); - xmlSecKeyDestroy(tempkey); - if(key == NULL) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - "xmlSecKeysMngrFindKey", - XMLSEC_ERRORS_R_XMLSEC_FAILED, - XMLSEC_ERRORS_NO_MESSAGE); - return(NULL); - } - if(xmlSecKeyGetValue(key) != NULL) { - return(key); - } - xmlSecKeyDestroy(key); - } + if(keyInfoCtx->keysMngr != NULL) + { + key = xmlSecKeysMngrFindKey(keyInfoCtx->keysMngr, keyname /*NULL*/, keyInfoCtx); + if(key == NULL) + { + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, + "xmlSecKeysMngrFindKey", + XMLSEC_ERRORS_R_XMLSEC_FAILED, + XMLSEC_ERRORS_NO_MESSAGE); + xmlSecKeyDestroy(tempkey); + return(NULL); + } + if(xmlSecKeyGetValue(key) != NULL) + { + xmlSecKeyDestroy(tempkey); + return(key); + } + xmlSecKeyDestroy(key); + } xmlSecError(XMLSEC_ERRORS_HERE, NULL, NULL, XMLSEC_ERRORS_R_KEY_NOT_FOUND, - XMLSEC_ERRORS_NO_MESSAGE); + XMLSEC_ERRORS_NO_MESSAGE); + xmlSecKeyDestroy(tempkey); return(NULL); } diff -r 361f875fa818 -r d10d750052f0 xmlsecurityengine/xmlsec/src/xmlsec_keysmngr.c --- a/xmlsecurityengine/xmlsec/src/xmlsec_keysmngr.c Thu Apr 01 00:31:02 2010 +0300 +++ b/xmlsecurityengine/xmlsec/src/xmlsec_keysmngr.c Tue Apr 27 18:31:15 2010 +0300 @@ -63,14 +63,16 @@ memset(mngr, 0, sizeof(xmlSecKeysMngr)); ret = xmlSecPtrListInitialize(&(mngr->storesList), xmlSecKeyDataStorePtrListId); - if(ret < 0) { - xmlSecError(XMLSEC_ERRORS_HERE, + if(ret < 0) + { + xmlSecError(XMLSEC_ERRORS_HERE, NULL, "xmlSecPtrListInitialize", XMLSEC_ERRORS_R_XMLSEC_FAILED, "xmlSecKeyDataStorePtrListId"); - return(NULL); - } + xmlFree(mngr); + return(NULL); + } return(mngr); } diff -r 361f875fa818 -r d10d750052f0 xmlsecurityengine/xmlsec/src/xmlsec_transforms.c --- a/xmlsecurityengine/xmlsec/src/xmlsec_transforms.c Thu Apr 01 00:31:02 2010 +0300 +++ b/xmlsecurityengine/xmlsec/src/xmlsec_transforms.c Tue Apr 27 18:31:15 2010 +0300 @@ -588,15 +588,17 @@ xmlSecAssert2(id != xmlSecTransformIdUnknown, NULL); transform = xmlSecTransformCreate(id); - if(!xmlSecTransformIsValid(transform)) { - xmlSecError(XMLSEC_ERRORS_HERE, + if(!xmlSecTransformIsValid(transform)) + { + xmlSecError(XMLSEC_ERRORS_HERE, NULL, "xmlSecTransformCreate", XMLSEC_ERRORS_R_XMLSEC_FAILED, "transform=%s", xmlSecErrorsSafeString(xmlSecTransformKlassGetName(id))); - return(NULL); - } + xmlSecTransformDestroy(transform); + return(NULL); + } ret = xmlSecTransformCtxAppend(ctx, transform); if(ret < 0) { @@ -634,27 +636,30 @@ xmlSecAssert2(id != xmlSecTransformIdUnknown, NULL); transform = xmlSecTransformCreate(id); - if(!xmlSecTransformIsValid(transform)) { - xmlSecError(XMLSEC_ERRORS_HERE, + if(!xmlSecTransformIsValid(transform)) + { + xmlSecError(XMLSEC_ERRORS_HERE, NULL, "xmlSecTransformCreate", XMLSEC_ERRORS_R_XMLSEC_FAILED, "transform=%s", xmlSecErrorsSafeString(xmlSecTransformKlassGetName(id))); - return(NULL); - } + xmlSecTransformDestroy(transform); + return(NULL); + } ret = xmlSecTransformCtxPrepend(ctx, transform); - if(ret < 0) { - xmlSecError(XMLSEC_ERRORS_HERE, + if(ret < 0) + { + xmlSecError(XMLSEC_ERRORS_HERE, NULL, "xmlSecTransformCtxPrepend", XMLSEC_ERRORS_R_XMLSEC_FAILED, "name=%s", xmlSecErrorsSafeString(xmlSecTransformGetName(transform))); - xmlSecTransformDestroy(transform); - return(NULL); - } + xmlSecTransformDestroy(transform); + return(NULL); + } return(transform); } @@ -1570,6 +1575,7 @@ "transform=%s", xmlSecErrorsSafeString(xmlSecTransformKlassGetName(id))); xmlFree(href); + xmlSecTransformDestroy(transform); return(NULL); } diff -r 361f875fa818 -r d10d750052f0 xmlsecurityengine/xmlsec/src/xmlsec_xmldsig.c --- a/xmlsecurityengine/xmlsec/src/xmlsec_xmldsig.c Thu Apr 01 00:31:02 2010 +0300 +++ b/xmlsecurityengine/xmlsec/src/xmlsec_xmldsig.c Tue Apr 27 18:31:15 2010 +0300 @@ -122,7 +122,7 @@ EXPORT_C int xmlSecDSigCtxInitialize(xmlSecDSigCtxPtr dsigCtx, xmlSecKeysMngrPtr keysMngr) { - int ret; + int ret,ret1; xmlSecAssert2(dsigCtx != NULL, -1); @@ -165,10 +165,19 @@ } /* references lists from SignedInfo and Manifest elements */ - xmlSecPtrListInitialize(&(dsigCtx->signedInfoReferences), + ret=xmlSecPtrListInitialize(&(dsigCtx->signedInfoReferences), xmlSecDSigReferenceCtxListId); - xmlSecPtrListInitialize(&(dsigCtx->manifestReferences), + ret1=xmlSecPtrListInitialize(&(dsigCtx->manifestReferences), xmlSecDSigReferenceCtxListId); + if(ret<0 ||ret1<0) + { + xmlSecError(XMLSEC_ERRORS_HERE, + NULL, + "xmlSecTransformCtxInitialize", + XMLSEC_ERRORS_R_XMLSEC_FAILED, + XMLSEC_ERRORS_NO_MESSAGE); + return(-1); + } dsigCtx->enabledReferenceUris = xmlSecTransformUriTypeAny; return(0); diff -r 361f875fa818 -r d10d750052f0 xmlsecurityengine/xmlsec/src/xmlsec_xmltree.c --- a/xmlsecurityengine/xmlsec/src/xmlsec_xmltree.c Thu Apr 01 00:31:02 2010 +0300 +++ b/xmlsecurityengine/xmlsec/src/xmlsec_xmltree.c Tue Apr 27 18:31:15 2010 +0300 @@ -1640,7 +1640,7 @@ xmlFree(content); return(-1); } - xmlFree(content); + if((stopOnUnknown != 0) && (tmp == 0)) { xmlSecError(XMLSEC_ERRORS_HERE, @@ -1649,9 +1649,12 @@ XMLSEC_ERRORS_R_XMLSEC_FAILED, "value=%s", xmlSecErrorsSafeString(content)); + xmlFree(content); return(-1); } + xmlFree(content); + (*mask) |= tmp; cur = xmlSecGetNextElementNode(cur->next); } diff -r 361f875fa818 -r d10d750052f0 xmlsecurityengine/xmlseccrypto/src/xmlsecc_bio.cpp --- a/xmlsecurityengine/xmlseccrypto/src/xmlsecc_bio.cpp Thu Apr 01 00:31:02 2010 +0300 +++ b/xmlsecurityengine/xmlseccrypto/src/xmlsecc_bio.cpp Tue Apr 27 18:31:15 2010 +0300 @@ -91,6 +91,7 @@ if(fileLen < 0) { xmlSecSetErrorFlag( KErrGeneral ); + fclose(fp); return(NULL); } fseek ( fp , 0L , SEEK_SET ); @@ -98,12 +99,14 @@ buf = (char *)malloc(sizeof(char)*(fileLen+1)); if(!buf) { xmlSecSetErrorFlag( KErrNoMemory ); + fclose(fp); return(NULL); } byteRead = fread(buf, sizeof(char), fileLen, fp); if(byteRead != fileLen) { free(buf); + fclose(fp); return(NULL); } @@ -114,6 +117,7 @@ { xmlSecSetErrorFlag( KErrNoMemory ); free(buf); + fclose(fp); return (NULL); } strcpy(tmpname, name); @@ -128,13 +132,14 @@ free(tmpname); } free(buf); + fclose(fp); return(NULL); } bio->mem = buf; bio->len = fileLen; bio->name = tmpname; - + fclose(fp); return bio; } diff -r 361f875fa818 -r d10d750052f0 xmlsecurityengine/xmlseccrypto/src/xmlsecc_evp.cpp --- a/xmlsecurityengine/xmlseccrypto/src/xmlsecc_evp.cpp Thu Apr 01 00:31:02 2010 +0300 +++ b/xmlsecurityengine/xmlseccrypto/src/xmlsecc_evp.cpp Tue Apr 27 18:31:15 2010 +0300 @@ -135,19 +135,21 @@ ctxSrc = xmlSecSymbianCryptoEvpKeyDataGetCtx(src); xmlSecAssert2(ctxSrc, -1); - if(ctxSrc->pKey) { + if(ctxSrc->pKey) + { ctxDst->pKey = xmlSecSymbianCryptoEvpKeyDup(ctxSrc->pKey); - ctxDst->pKey->duplicate=0; - ctxSrc->pKey->duplicate=1; - if(!ctxDst->pKey) { - xmlSecError(XMLSEC_ERRORS_HERE, - xmlSecErrorsSafeString(xmlSecKeyDataGetName(dst)), - "xmlSecSymbianCryptoEvpKeyDup", - XMLSEC_ERRORS_R_XMLSEC_FAILED, - XMLSEC_ERRORS_NO_MESSAGE); - return(-1); - } - } + if(!ctxDst->pKey) + { + xmlSecError(XMLSEC_ERRORS_HERE, + xmlSecErrorsSafeString(xmlSecKeyDataGetName(dst)), + "xmlSecSymbianCryptoEvpKeyDup", + XMLSEC_ERRORS_R_XMLSEC_FAILED, + XMLSEC_ERRORS_NO_MESSAGE); + return(-1); + } + ctxDst->pKey->duplicate=0; + ctxSrc->pKey->duplicate=1; + } return(0); } @@ -1401,6 +1403,7 @@ return(-1); } + /* if(!rsa) { xmlSecError(XMLSEC_ERRORS_HERE, xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)), @@ -1409,7 +1412,7 @@ XMLSEC_ERRORS_NO_MESSAGE); return(-1); } - + */ cur = xmlSecGetNextElementNode(node->children); /* first is Modulus node. It is REQUIRED because we do not support Seed and PgenCounter*/ @@ -1652,6 +1655,7 @@ "sc_load_key", XMLSEC_ERRORS_R_CRYPTO_FAILED, "sizeBits=%d", sizeBits); + sc_pkey_free(pKey); return(-1); } @@ -1667,17 +1671,22 @@ "sc_generate_key", XMLSEC_ERRORS_R_CRYPTO_FAILED, "sizeBits=%d", sizeBits); - return(-1); + sc_pkey_free(pKey); + return(-1); } } - if (!pKey->load) { - xmlSecError(XMLSEC_ERRORS_HERE, + if (!pKey->load) + { + + xmlSecError(XMLSEC_ERRORS_HERE, xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)), "sc_generate_key", XMLSEC_ERRORS_R_CRYPTO_FAILED, "sizeBits=%d", sizeBits); - return(-1); - } + + sc_pkey_free(pKey); + return(-1); + } ret = xmlSecSymbianCryptoKeyDataRsaAdoptEvp(data, pKey); if(ret < 0) { @@ -1705,6 +1714,7 @@ return(-1); } */ + sc_pkey_free(pKey); return(0); } diff -r 361f875fa818 -r d10d750052f0 xmlsecurityengine/xmlseccrypto/src/xmlsecc_md.cpp --- a/xmlsecurityengine/xmlseccrypto/src/xmlsecc_md.cpp Thu Apr 01 00:31:02 2010 +0300 +++ b/xmlsecurityengine/xmlseccrypto/src/xmlsecc_md.cpp Tue Apr 27 18:31:15 2010 +0300 @@ -190,7 +190,7 @@ /* Set key for HMAC */ int sc_md_setkey(sc_md_hd_t hd, unsigned char *buffer, size_t length) { - TInt err; + TInt err =KErrNone; if (!hd || !buffer || length <=0) return KErrArgument; diff -r 361f875fa818 -r d10d750052f0 xmlsecurityengine/xmlseccrypto/src/xmlsecc_x509.cpp --- a/xmlsecurityengine/xmlseccrypto/src/xmlsecc_x509.cpp Thu Apr 01 00:31:02 2010 +0300 +++ b/xmlsecurityengine/xmlseccrypto/src/xmlsecc_x509.cpp Tue Apr 27 18:31:15 2010 +0300 @@ -577,6 +577,7 @@ size = xmlSecSymbianCryptoKeyDataX509GetCertsSize(src); for(pos = 0; pos < size; ++pos) { certSrc = xmlSecSymbianCryptoKeyDataX509GetCert(src, pos); + certDst = xmlSecSymbianCryptoKeyDataX509GetCert(dst, pos); if(!certSrc) { xmlSecError(XMLSEC_ERRORS_HERE, xmlSecErrorsSafeString(xmlSecKeyDataGetName(src)), @@ -610,6 +611,7 @@ size = xmlSecSymbianCryptoKeyDataX509GetCrlsSize(src); for(pos = 0; pos < size; ++pos) { crlSrc = xmlSecSymbianCryptoKeyDataX509GetCrl(src, pos); + crlDst =xmlSecSymbianCryptoKeyDataX509GetCrl(dst, pos); if(!crlSrc) { xmlSecError(XMLSEC_ERRORS_HERE, xmlSecErrorsSafeString(xmlSecKeyDataGetName(src)), @@ -618,7 +620,6 @@ "pos=%d", pos); return(-1); } - if(!crlDst) { xmlSecError(XMLSEC_ERRORS_HERE, xmlSecErrorsSafeString(xmlSecKeyDataGetName(dst)), @@ -1106,8 +1107,7 @@ xmlSecKeyDataStorePtr x509Store; xmlChar* subject; X509* cert; - X509* cert2 = NULL; - int ret; + //X509* cert2 = NULL; xmlSecAssert2(xmlSecKeyDataCheckId(data, xmlSecSymbianCryptoKeyDataX509Id), -1); xmlSecAssert2(node, -1); @@ -1142,8 +1142,6 @@ cert = xmlSecSymbianCryptoX509StoreFindCert(x509Store, subject, NULL, NULL, NULL, keyInfoCtx); if(!cert){ - xmlFree(subject); - if((keyInfoCtx->flags & XMLSEC_KEYINFO_FLAGS_X509DATA_STOP_ON_UNKNOWN_CERT) != 0) { xmlSecError(XMLSEC_ERRORS_HERE, xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)), @@ -1151,11 +1149,15 @@ XMLSEC_ERRORS_R_CERT_NOT_FOUND, "subject=%s", xmlSecErrorsSafeString(subject)); + xmlFree(subject); return(-1); } + xmlFree(subject); return(0); } - + + //dead error condition + /* if(!cert2) { xmlSecError(XMLSEC_ERRORS_HERE, xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)), @@ -1176,7 +1178,7 @@ xmlFree(subject); return(-1); } - + */ xmlFree(subject); return(0); } @@ -1225,8 +1227,7 @@ xmlChar *issuerName; xmlChar *issuerSerial; X509* cert; - X509* cert2 = NULL; - int ret; + //X509* cert2 = NULL; xmlSecAssert2(xmlSecKeyDataCheckId(data, xmlSecSymbianCryptoKeyDataX509Id), -1); xmlSecAssert2(node, -1); @@ -1320,23 +1321,27 @@ issuerSerial, NULL, keyInfoCtx); - if(!cert){ - xmlFree(issuerSerial); - xmlFree(issuerName); - - if((keyInfoCtx->flags & XMLSEC_KEYINFO_FLAGS_X509DATA_STOP_ON_UNKNOWN_CERT) != 0) { - xmlSecError(XMLSEC_ERRORS_HERE, + if(!cert) + { + if((keyInfoCtx->flags & XMLSEC_KEYINFO_FLAGS_X509DATA_STOP_ON_UNKNOWN_CERT) != 0) + { + xmlSecError(XMLSEC_ERRORS_HERE, xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)), NULL, XMLSEC_ERRORS_R_CERT_NOT_FOUND, "issuerName=%s;issuerSerial=%s", xmlSecErrorsSafeString(issuerName), xmlSecErrorsSafeString(issuerSerial)); - return(-1); - } - return(0); - } + xmlFree(issuerSerial); + xmlFree(issuerName); + return(-1); + } + xmlFree(issuerSerial); + xmlFree(issuerName); + return(0); + } + /* if(!cert2) { xmlSecError(XMLSEC_ERRORS_HERE, xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)), @@ -1359,7 +1364,7 @@ xmlFree(issuerName); return(-1); } - + */ xmlFree(issuerSerial); xmlFree(issuerName); return(0); @@ -1410,8 +1415,8 @@ xmlSecErrorsSafeString(xmlSecNodeX509SerialNumber)); return(-1); } - - /* write data */ + /* + //write data if(!buf) { xmlSecError(XMLSEC_ERRORS_HERE, NULL, @@ -1420,9 +1425,7 @@ XMLSEC_ERRORS_NO_MESSAGE); return(-1); } - xmlNodeSetContent(issuerNameNode, buf); - xmlFree(buf); - + if(!buf) { xmlSecError(XMLSEC_ERRORS_HERE, NULL, @@ -1431,6 +1434,8 @@ XMLSEC_ERRORS_NO_MESSAGE); return(-1); } + */ + xmlNodeSetContent(issuerNameNode, buf); xmlNodeSetContent(issuerNumberNode, buf); xmlFree(buf); @@ -1445,8 +1450,6 @@ xmlSecKeyDataStorePtr x509Store; xmlChar* ski; X509* cert; - X509* cert2 = NULL; - int ret; xmlSecAssert2(xmlSecKeyDataCheckId(data, xmlSecSymbianCryptoKeyDataX509Id), -1); xmlSecAssert2(node, -1); @@ -1482,8 +1485,6 @@ cert = xmlSecSymbianCryptoX509StoreFindCert(x509Store, NULL, NULL, NULL, ski, keyInfoCtx); if(!cert){ - xmlFree(ski); - if((keyInfoCtx->flags & XMLSEC_KEYINFO_FLAGS_X509DATA_STOP_ON_UNKNOWN_CERT) != 0) { xmlSecError(XMLSEC_ERRORS_HERE, xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)), @@ -1491,11 +1492,15 @@ XMLSEC_ERRORS_R_CERT_NOT_FOUND, "ski=%s", xmlSecErrorsSafeString(ski)); + xmlFree(ski); return(-1); } + xmlFree(ski); return(0); } - + +//dead error condition +/* if(!cert2) { xmlSecError(XMLSEC_ERRORS_HERE, xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)), @@ -1505,7 +1510,7 @@ xmlFree(ski); return(-1); } - + ret = xmlSecSymbianCryptoKeyDataX509AdoptCert(data, cert2); if(ret < 0) { xmlSecError(XMLSEC_ERRORS_HERE, @@ -1516,6 +1521,7 @@ xmlFree(ski); return(-1); } + */ xmlFree(ski); return(0); @@ -2440,8 +2446,10 @@ "xmlSecSymbianCryptoKeyDataX509VerifyAndExtractKey", XMLSEC_ERRORS_R_XMLSEC_FAILED, XMLSEC_ERRORS_NO_MESSAGE); + X509_free(cert); return(-1); } + X509_free(cert); return(0); } diff -r 361f875fa818 -r d10d750052f0 xmlsecurityengine/xmlsecwrapper/src/xmlsecwinit.cpp --- a/xmlsecurityengine/xmlsecwrapper/src/xmlsecwinit.cpp Thu Apr 01 00:31:02 2010 +0300 +++ b/xmlsecurityengine/xmlsecwrapper/src/xmlsecwinit.cpp Tue Apr 27 18:31:15 2010 +0300 @@ -59,9 +59,10 @@ // UnSet global state for dll // --------------------------------------------------------------------------- // -void XmlSecUnsetTlsD( void* aGlobalState ) +void XmlSecUnsetTlsDL( void* aGlobalState ) { - delete aGlobalState; + CleanupStack::PushL(aGlobalState); + CleanupStack::PopAndDestroy(aGlobalState); Dll::SetTls( NULL ); } @@ -79,7 +80,7 @@ } if(gs->iUserCount == 0) { - CleanupStack::PushL( TCleanupItem( XmlSecUnsetTlsD, gs ) ); + CleanupStack::PushL( TCleanupItem( XmlSecUnsetTlsDL, gs ) ); XmlEngineAttachL(); RXmlEngDOMImplementation dom; diff -r 361f875fa818 -r d10d750052f0 xmlsecurityengine/xmlsecwrapper/src/xmlsecwsign.cpp --- a/xmlsecurityengine/xmlsecwrapper/src/xmlsecwsign.cpp Thu Apr 01 00:31:02 2010 +0300 +++ b/xmlsecurityengine/xmlsecwrapper/src/xmlsecwsign.cpp Tue Apr 27 18:31:15 2010 +0300 @@ -214,11 +214,13 @@ // Reset template settings // --------------------------------------------------------------------------- // -void TemplateCleanup(TAny* aPref) +void TemplateCleanupL(TAny* aPref) { + if(aPref) { - delete aPref; + CleanupStack::PushL(aPref); + CleanupStack::PopAndDestroy(aPref); xmlSetPrefix(NULL); } xmlSetNewLineFlag(1); @@ -625,7 +627,7 @@ pref = (unsigned char*) XmlEngXmlCharFromDes8L(aPref); xmlSetPrefix(pref); } - CleanupStack::PushL(TCleanupItem(Sign::TemplateCleanup,(TAny*)pref)); + CleanupStack::PushL(TCleanupItem(Sign::TemplateCleanupL,(TAny*)pref)); xmlNodePtr signNode = NULL; xmlNodePtr refNode = NULL;