W3C home > Mailing lists > Public > www-lib@w3.org > July to September 2000

Solution for possible crash if using SSL

From: Kallweit, Heiner <Heiner.Kallweit@commerzbank.com>
Date: Wed, 26 Jul 2000 14:09:02 +0200
Message-ID: <01EBDB2D6DFDD211A98200805FF50CF901188D64@SV002871>
To: "'www-lib@w3.org'" <www-lib@w3.org>
Hi,

I ran into serious trouble when using a CGI-programm that (not only)
forwards
requests via Libwww and SSL. Every 100th request I got a core dump.
Eventually I found out that there is a recursive function call. To cut a
long
story short: HTHost_forceFlush -> HTTPEvent_Flush ->
HTBufferWriter_lazyFlush
-> HTSSLWriter_write -> HTSSLReader_read -> HTHost_forceFlush
If your machine is fast enough (mine was) this can cause a stack overflow.
I stopped the recursion by changing HTHost_forceFlush to the following:

PUBLIC int HTHost_forceFlush(HTHost * host)
{
    static BOOL in_flush=NO;
    HTNet * targetNet = (HTNet *) HTList_lastObject(host->pipeline);
    int ret;
    if (in_flush || targetNet == NULL) return HT_ERROR;
    HTTRACE(CORE_TRACE, "Host Event.. FLUSH passed to `%s\'\n" _
 
HTAnchor_physical(HTRequest_anchor(HTNet_request(targetNet))));
    host->forceWriteFlush = in_flush = YES;
    while ((ret = (*targetNet->event.cbf)(HTChannel_socket(host->channel),
targetNet->event.param, Event_FLUSH))==HT_WOULD_BLOCK);
    host->forceWriteFlush = in_flush = NO;
    return ret;
}

Until now I found no side effect.

Regards, Heiner
Received on Wednesday, 26 July 2000 08:09:44 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:37 GMT