[[EMAIL PROTECTED] - Mon Aug 12 13:15:25 2002]:
> It looks to me like SSL_CTX_flush_sessions() must be always called
> just
> before SSL_CTX_free() if session caching callback functions are
> installed.
>
> There appears to be a bug in SSL_CTX_free():
>
> ...
>
> CRYPTO_free_ex_data(ssl_ctx_meth,(char *)a,&a->ex_data);
>
> if (a->sessions != NULL)
> {
> SSL_CTX_flush_sessions(a,0);
> lh_free(a->sessions);
> }
yup, I fixed some similar things in [RSA|DSA|<etc>]_free() functions a
while ago. Those cases were more clear-cut though, because the
structures in question had virtual-function tables ("methods") with
finish() handlers (destructors) - distructor callbacks are a clearer
case than callback hooks into a single member variable's cleanup.
Let me clarify my point, it's not immediately clear to me whether the
SSL_CTX_flush_sessions() and lh_free() should occur before the ex_data
cleanup - eg. what if someone registered an ex_data index for the
SSL_CTX type with a non-NULL "free" callback? In particular, what if
there's a "free" ex_data callback invoked by the CRYPTO_free_ex_data()
function that needs "a->sessions"? :-)
I think it's unlikely, but I'd guess off the top of my head that
something like the following would be less risky;
if (a->sessions != NULL)
SSL_CTX_flush_sessions(a,0);
CRYPTO_free_ex_data(ssl_ctx_meth,(char *)a,&a->ex_data);
if (a->sessions != NULL)
lh_free(a->sessions);
how does that look to you? Any of the more SSL-savvy hackers out there
have any comments? The code in ssl/ can bite some times ...
--
Geoff Thorpe, RT/openssl.org
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]