<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=FR link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='color:#1F497D'>Hi,<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Following my previous mail, here attached is an updated patch against 1.02e to fix the SRP VBASE memory leaks.<br>I understand the VBASE stuff is not a TLS critical component, but it is part of the SRP command line tool.<br><br>NB : it's a pity that the base64 encoding is not the same than the one use elsewhere by OpenSSL.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Regards,<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Michel.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>De :</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> openssl-dev [mailto:openssl-dev-bounces@openssl.org] <b>De la part de</b> Michel<br><b>Envoyé :</b> lundi 23 mars 2015 12:10<br><b>À :</b> openssl-dev@openssl.org<br><b>Objet :</b> [openssl-dev] SRP memory leaks and more leaks<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Hi,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Trying to use the 'SRP' code, I found two kinds of memory leaks in srp_vfy.c .<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>1)  The first kind was due to bad use of OpenSSL 'stack' code and cumbersome / confusing names of structure / functions.<o:p></o:p></p><p class=MsoNormal>In this case, leaks occurs when loading a verifier file containing 'index' lines.<o:p></o:p></p><p class=MsoNormal>Two structures are used : SRP_gN and SRP_gN_cache.<o:p></o:p></p><p class=MsoNormal>And unfortunatly, the SRP_gN_free function free a SRP_gN_cache structure.<o:p></o:p></p><p class=MsoNormal>The SRP_VBASE_free() function, line 276, should call :<o:p></o:p></p><p class=MsoNormal>sk_SRP_gN_cache_pop_free(vb->gN_cache, SRP_gN_cache_free);<o:p></o:p></p><p class=MsoNormal>instead of :<o:p></o:p></p><p class=MsoNormal>sk_SRP_gN_cache_free(vb->gN_cache);<o:p></o:p></p><p class=MsoNormal>And consequently the SRP_gN_cache_free() function, lines 305-312, has to move before SRP_VBASE_free()<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The attached patch solve this kind of leaks.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>2) When simulating a 'fake user' as per RFC 5054, § '2.5.1.3.  Unknown SRP User Name',<o:p></o:p></p><p class=MsoNormal>the SRP_VBASE_get_by_user() function returns a newly allocated SRP_user_pwd structure whose adress is not kept anywhere else.<o:p></o:p></p><p class=MsoNormal>So, the caller should free it later, but from outside the function, there is no way to distinguish between 'fake users' and real ones <o:p></o:p></p><p class=MsoNormal>which are managed and freed throught the use of the SRP_VBASE structure / functions.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I am afraid there is no other solution than changing the SRP_VBASE_get_by_user() function prototype.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>It is better I do not share here my opinion about the comments below : <o:p></o:p></p><p class=MsoNormal>/* need to check whether there are memory leaks */, s_server.c line 433<o:p></o:p></p><p class=MsoNormal>or :<o:p></o:p></p><p class=MsoNormal>/* there may be still some leaks to fix, … */ srp_vfy.c line 449<o:p></o:p></p><p class=MsoNormal>>:(<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Hope this will save time to other users,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Michel.<o:p></o:p></p></div></body></html>