[xmlsec] Memory Leak when using xmlSecTmplX509DataAddSubjectName

Aleksey Sanin aleksey at aleksey.com
Mon Jun 3 07:33:22 PDT 2013


Good catch. I think I found it

https://git.gnome.org/browse/xmlsec/commit/?id=46896def4dfe16b16131869b03db000314413e25

Can you try it? I don't have windows env these days.

Aleksey

On 6/3/13 7:00 AM, Alexwell Sandro wrote:
> I found memory leak with xmlSecTmplX509DataAddSubjectName function.
> 
> I used example from: Signing a dynamicaly created template. sign2.c.
>  <http://www.aleksey.com/xmlsec/api/xmlsec-examples-sign-dynamimc-template.html>
> 
> *To generate template:*
> (...)
> xmlNodePtr keyInfoNode = xmlSecTmplSignatureEnsureKeyInfo(signNode, NULL);
> xmlNodePtr x509DataNode = xmlSecTmplKeyInfoAddX509Data(keyInfoNode);
> xmlSecTmplX509DataAddSubjectName(x509DataNode);
> xmlSecTmplX509DataAddCertificate(x509DataNode);
> (...)
> 
> *Result:*
> (...)
> <ds:KeyInfo>
> <ds:X509Data>
> <ds:X509SubjectName/>
> <ds:X509Certificate/>
> </ds:X509Data>
> </ds:KeyInfo>
> (...)
> 
> *When sign the template occurs memory leak.*
> 
> Data:
>     43 00 4E 00    3D 00 41 00    4C 00 45 00    58 00 20 00    
> C.N.=.A. L.E.X...
> ...
> 
> *When I remove "xmlSecTmplX509DataAddSubjectName"*
> xmlNodePtr keyInfoNode = xmlSecTmplSignatureEnsureKeyInfo(signNode, NULL);
> xmlNodePtr x509DataNode = xmlSecTmplKeyInfoAddX509Data(keyInfoNode);
> /// xmlSecTmplX509DataAddSubjectName(x509DataNode);/
> xmlSecTmplX509DataAddCertificate(x509DataNode);
> 
> No memory leak detected!
> 
> *The same problem when verify the signature.*
> With <ds:X509SubjectName> Two Memory Leaks.
> 
>  Data:
>     43 4E 3D 41    4C 45 58 20    53 41 4E 44    52 4F 20 44     CN=ALEX. S
> ...
> 
>  Data:
>     43 4E 3D 41    4C 45 58 20    53 41 4E 44    52 4F 20 44     CN=ALEX. S
> ...
> 
> *Without  <ds:X509SubjectName> No Memory Leak.*
> 
> *Another detail, when I use:*
> xmlNodePtr keyInfoNode = xmlSecTmplSignatureEnsureKeyInfo(signNode, NULL);
> xmlNodePtr x509DataNode = xmlSecTmplKeyInfoAddX509Data(keyInfoNode);
> 
> *result:*
> <KeyInfo>
> <X509Data>
> <X509Certificate>MIIE3zCCA8e...
> 
> *When I use:*
> xmlNodePtr keyInfoNode = xmlSecTmplSignatureEnsureKeyInfo(signNode, NULL);
> xmlNodePtr x509DataNode = xmlSecTmplKeyInfoAddX509Data(keyInfoNode);
> xmlSecTmplX509DataAddCertificate(x509DataNode);
> 
> *result with breakline:*
> <KeyInfo>
> <X509Data>
> 
> <X509Certificate>MIIE3zCCA8e...
> 
> *When I use:*
> xmlNodePtr x509DataNode = xmlSecTmplKeyInfoAddX509Data(keyInfoNode);
> xmlSecTmplX509DataAddSubjectName(x509DataNode);
> 
> *result with breakline:*
> <X509Data>
> 
> <X509SubjectName>CN=ALEX...
> 
> *How to fix the memory leak?*
> 
> tags: windows 7 64 bits, visual studio 2010.


More information about the xmlsec mailing list