Subject: Memory leaks in libssh2

Memory leaks in libssh2

From: Philippe Lemoine <plemoine_at_quazal.com>
Date: Fri, 10 Dec 2010 09:10:03 -0500

 

Hello, I just want to report fixes that I have done in the lib. This
email address has been provided by Daniel Stenberg.

 

 

 

Currently, we are using 1.2.4 but even though I compared the sources
with the newest release - 1.2.7 - I did not see those fixes there.

 

 

 

In the files I am forwarding you, there are comments marked as < QUAZAL
>, which indicate the modifications. The reason of those fixes were to
handle properly connection termination in case of an unexpected socket
error.

 

 

 

Best regards

 

Philippe

 

 

NOTE that those changes are made against files from version 1.2.4. If it
would help, I can provide you the modified files.

 

---- transport.c -------------------------

 

Index: transport.c

===================================================================

RCS file: \devenv\CVSROOT/jade/Tools/libssh2/transport.c,v

retrieving revision 1.1.4.7

retrieving revision 1.1.4.8

diff -r1.1.4.7 -r1.1.4.8

833c833,839

<
&session->local.crypt_abstract))

---
>
&session->local.crypt_abstract))  {
> 
>                 //  QUAZAL ADDED BEGIN
>                 //  bug:6144: Extra cleanup added, in case of failure
>                 LIBSSH2_FREE(session, p->outbuf);
>                 p->outbuf = NULL;
>                 //  QUAZAL ADDED END
834a841
>             }
861a869,873
>         //  QUAZAL ADDED BEGIN
>         //  bug:6144: Extra cleanup added, in case of failure
>         LIBSSH2_FREE(session, p->outbuf);
>         p->outbuf = NULL;
>         //  QUAZAL ADDED END
 
 
 
---- sftp.c -------------------------
 
Index: sftp.c
===================================================================
RCS file: \devenv\CVSROOT/jade/Tools/libssh2/sftp.c,v
retrieving revision 1.1.4.4
retrieving revision 1.1.4.5
diff -r1.1.4.4 -r1.1.4.5
44a45,49
> //  QUAZAL ADDED BEGIN
> #include "libssh2_qtrace.h"
> //  QUAZAL ADDED END
> 
> 
90a96
> 
531c537
< 
---
> 
605a612
> 
790a798
> 
953a962
> 
1700a1710,1713
> //  QUAZAL ADDED BEGIN
> //  bug:6144 Missing cleanup from original lib
>             LIBSSH2_FREE(session, handle);
> //  QUAZAL ADDED END
1728a1742,1745
> //  QUAZAL ADDED BEGIN
> //  bug:6144 Missing cleanup from original lib
>             LIBSSH2_FREE(session, handle);
> //  QUAZAL ADDED END
1746a1764,1767
> //  QUAZAL ADDED BEGIN
> //  bug:6144 Missing cleanup from original lib
>             LIBSSH2_FREE(session, handle);
> //  QUAZAL ADDED END
1760a1782,1785
> //  QUAZAL ADDED BEGIN
> //  bug:6144 Missing cleanup from original lib
>         LIBSSH2_FREE(session, handle);
> //  QUAZAL ADDED END
1777a1803
> 
 
 
---- channel.c -------------------------
 
Index: channel.c
===================================================================
RCS file: \devenv\CVSROOT/jade/Tools/libssh2/channel.c,v
retrieving revision 1.1.4.5
retrieving revision 1.1.4.6
diff -r1.1.4.5 -r1.1.4.6
52a53,57
> //  QUAZAL ADDED BEGIN
> #include "libssh2_qtrace.h"
> //  QUAZAL ADDED END
> 
> 
156a162
> 
2024c2030
< 
---
> 
2240c2246
< 
---
> 
2266c2272,2275
<             return retcode;
---
> // QUAZAL MODIFIED BEGIN
> //  bug:6144: returning here cut off necessary cleanup, which causes
leaks.
> //            return retcode;
> // QUAZAL MODIFIED END
2290c2299
< 
---
> 
2405c2414,2418
<             return rc;
---
> 
> // QUAZAL MODIFIED BEGIN
> //  bug:6144: returning here cut off necessary cleanup, which causes
leaks.
> //            return rc;
> // QUAZAL MODIFIED END
 
 
 
Philippe Lemoine
<mailto:plemoine_at_quazal.com> plemoine_at_quazal.com
Senior Software Designer
Quazal Technologies Inc.
555 Rene-Levesque West
Suite 1800
Montreal, Quebec, Canada
H2Z 1B1
Phone: 514-395-4646
Fax: 514-395-6006
 

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-12-10