Re: OpenSSL with KRB5 support, memory leak kssl_ctx_new()

2003-09-27 Thread Richard Levitte - VMS Whacker
In message [EMAIL PROTECTED] on Fri, 26 Sep 2003 16:27:38 -0400, Andrew Mann [EMAIL 
PROTECTED] said:

amann ssl_lib.c  function SSL_free() does not appear to free this memory.
amann 
amann  As a note, the system libraries here are openssl 0.9.7a, but I'm 
amann looking through the 0.9.7b source and the handling doesn't appear any 
amann different there.
amann  In fact, kssl_ctx_free() isn't called from anywhere in ssl/*.c  (it's 
amann commented out from one location).
amann 
amann  Seems like a simple fix:
amann 
amann diff -up ssl_lib.c ../ssl-modified/ssl_lib.c
amann --- ssl_lib.c   2003-01-30 06:00:37.0 -0500
amann +++ ../ssl-modified/ssl_lib.c   2003-09-26 15:36:14.0 -0400
amann @@ -473,6 +473,10 @@ void SSL_free(SSL *s)
amann 
amann  if (s-method != NULL) s-method-ssl_free(s);
amann 
amann +#ifndefOPENSSL_NO_KRB5
amann +   if (s-kssl_ctx != NULL) kssl_ctx_free(s-kssl_ctx);
amann +#endif /* OPENSSL_NO_KRB5 */
amann +
amann  OPENSSL_free(s);
amann  }

Thanks for your patch, I just applied it in the 0.9.7 and 0.9.8-dev
branches.

-- 
Richard Levitte   \ Tunnlandsvägen 3  \ [EMAIL PROTECTED]
[EMAIL PROTECTED]  \ S-168 36  BROMMA  \ T: +46-8-26 52 47
\  SWEDEN   \ or +46-708-26 53 44
Procurator Odiosus Ex Infernis-- [EMAIL PROTECTED]
Member of the OpenSSL development team: http://www.openssl.org/

Unsolicited commercial email is subject to an archival fee of $400.
See http://www.stacken.kth.se/~levitte/mail/ for more info.
__
OpenSSL Project http://www.openssl.org
Development Mailing List   [EMAIL PROTECTED]
Automated List Manager   [EMAIL PROTECTED]


OpenSSL with KRB5 support, memory leak kssl_ctx_new()

2003-09-26 Thread Andrew Mann
	Running an app that uses OpenSSL here through valgrind:

==10427== 6400 bytes in 200 blocks are definitely lost in loss record 4 of 4
==10427==at 0x40029888: calloc (vg_replace_malloc.c:273)
==10427==by 0x403C61C7: kssl_ctx_new (in /lib/libssl.so.0.9.7a)
==10427==by 0x403B8AE7: SSL_new (in /lib/libssl.so.0.9.7a)
ssl_lib.c line 244 of 2315   function SSL_new()
#ifndef OPENSSL_NO_KRB5
s-kssl_ctx = kssl_ctx_new();
#endif  /* OPENSSL_NO_KRB5 */


ssl_lib.c  function SSL_free() does not appear to free this memory.

	As a note, the system libraries here are openssl 0.9.7a, but I'm 
looking through the 0.9.7b source and the handling doesn't appear any 
different there.
	In fact, kssl_ctx_free() isn't called from anywhere in ssl/*.c  (it's 
commented out from one location).

	Seems like a simple fix:

diff -up ssl_lib.c ../ssl-modified/ssl_lib.c
--- ssl_lib.c   2003-01-30 06:00:37.0 -0500
+++ ../ssl-modified/ssl_lib.c   2003-09-26 15:36:14.0 -0400
@@ -473,6 +473,10 @@ void SSL_free(SSL *s)
if (s-method != NULL) s-method-ssl_free(s);

+#ifndefOPENSSL_NO_KRB5
+   if (s-kssl_ctx != NULL) kssl_ctx_free(s-kssl_ctx);
+#endif /* OPENSSL_NO_KRB5 */
+
OPENSSL_free(s);
}
Andrew

__
OpenSSL Project http://www.openssl.org
Development Mailing List   [EMAIL PROTECTED]
Automated List Manager   [EMAIL PROTECTED]