Hi,

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. 

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

Juraj
--- 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
@@ -308,6 +308,8 @@
    {
     if(request_body)
       {
+       close(cgi_out[0]);
+       
        int cgi_in=CreateTempSpoolFile();
 
        if(cgi_in==-1)
@@ -347,7 +349,6 @@
           PrintMessage(Fatal,"Cannnot create standard output for local CGI program '%s' [%!s].", file);
        close(cgi_out[1]);
       }
-    close(cgi_out[0]);
 
     execl(file, file, NULL);
 

Reply via email to