Juraj Variny <[EMAIL PROTECTED]> writes:

> I ran into especially nasty bug in wwwoffle CGI interface. The output of any 
> CGI script was completely empty except HTTP headers. In older versions (AFAIK 
> 2.7e-2.8) of wwwoffle the bug was triggered sometimes by several 
> online/offline/fetch cycles. With debugging output turned on, it happened 
> never. With 2.8b it happened always after fresh start (except with debugging 
> turned on, of course :-). This enabled me to nail it down. Here is simple 
> bugfix patch against cgi.c in 2.8b. 

I can't replicate the problem here.  The code worked in previous
versions of WWWOFFLE and still works in the current version as far as
I can see.

> Hmmm, maybe splint could be made to check for trashing live file descriptor 
> with dup2().

At first I couldn't see the problem, but I think that I have now.
When cgi_out[0] is closed it might be file descriptor 1 that
cgi_out[1] was replicated onto by calling dup2().

This would explain why I don't see the problem, I use the '-d' option
to wwwoffled which doesn't close file descriptors 0 and 1 and uses 2
for logging (I have changed it to close 0 and 1 in this case as well).

> --- cgi.c     2004-02-15 19:52:37.115156808 +0100
> +++ ../../wwwoffle-2.8.modified/src/cgi.c     2004-02-15 19:57:08.989825576 +0100

[snip patch]

I think that you need to close cgi_out[0] before the if() statement
rather than inside it since it should be closed in both cases.

It is probably also a good idea to make sure that there are file
descriptors 0, 1 and 2 when the CGI is run.  There will be a 1 in all
cases and a 0 if using a POST request, but not a 2 unless using the -d
option.

-- 
Andrew.
----------------------------------------------------------------------
Andrew M. Bishop                             [EMAIL PROTECTED]
                                      http://www.gedanken.demon.co.uk/

WWWOFFLE users page:
        http://www.gedanken.demon.co.uk/wwwoffle/version-2.8/user.html

Reply via email to