You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@apache.org on 2002/03/20 14:57:08 UTC

cvs commit: httpd-2.0/modules/generators mod_cgi.c mod_cgid.c

trawick     02/03/20 05:57:08

  Modified:    .        CHANGES
               modules/generators mod_cgi.c mod_cgid.c
  Log:
  Get nph- CGI scripts working again by avoiding filters that can't
  possibly deal with a script that generates the protocol header.
  
  PR:       8902, 8907, 9983
  
  Revision  Changes    Path
  1.648     +3 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.647
  retrieving revision 1.648
  diff -u -r1.647 -r1.648
  --- CHANGES	20 Mar 2002 07:10:21 -0000	1.647
  +++ CHANGES	20 Mar 2002 13:57:07 -0000	1.648
  @@ -1,5 +1,8 @@
   Changes with Apache 2.0.34-dev
   
  +  *) Get nph- CGI scripts working again.  PRs 8902, 8907, 9983
  +     [Jeff Trawick]
  +
     *) Upgraded PCRE library to latest version 3.9 [Brian Pane]
   
     *) Add accessor function to set r->content_type. From now on,
  
  
  
  1.123     +13 -0     httpd-2.0/modules/generators/mod_cgi.c
  
  Index: mod_cgi.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/generators/mod_cgi.c,v
  retrieving revision 1.122
  retrieving revision 1.123
  diff -u -r1.122 -r1.123
  --- mod_cgi.c	20 Mar 2002 01:58:46 -0000	1.122
  +++ mod_cgi.c	20 Mar 2002 13:57:08 -0000	1.123
  @@ -739,6 +739,19 @@
       }
   
       if (script_in && nph) {
  +        struct ap_filter_t *cur;
  +        
  +        /* get rid of all filters up through protocol...  since we
  +         * haven't parsed off the headers, there is no way they can
  +         * work
  +         */
  +
  +        cur = r->proto_output_filters;
  +        while (cur && cur->frec->ftype < AP_FTYPE_CONNECTION) {
  +            cur = cur->next;
  +        }
  +        r->output_filters = r->proto_output_filters = cur;
  +
           bb = apr_brigade_create(r->pool);
   	b = apr_bucket_pipe_create(script_in);
   	APR_BRIGADE_INSERT_TAIL(bb, b);
  
  
  
  1.120     +13 -0     httpd-2.0/modules/generators/mod_cgid.c
  
  Index: mod_cgid.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/generators/mod_cgid.c,v
  retrieving revision 1.119
  retrieving revision 1.120
  diff -u -r1.119 -r1.120
  --- mod_cgid.c	20 Mar 2002 01:58:46 -0000	1.119
  +++ mod_cgid.c	20 Mar 2002 13:57:08 -0000	1.120
  @@ -1159,11 +1159,24 @@
       } 
   
       if (nph) {
  +        struct ap_filter_t *cur;
  +        
           /* Passing our socket down the filter chain in a pipe bucket
            * gives up the responsibility of closing the socket, so
            * get rid of the cleanup.
            */
           apr_pool_cleanup_kill(r->pool, (void *)sd, close_unix_socket);
  +
  +        /* get rid of all filters up through protocol...  since we
  +         * haven't parsed off the headers, there is no way they can
  +         * work
  +         */
  +
  +        cur = r->proto_output_filters;
  +        while (cur && cur->frec->ftype < AP_FTYPE_CONNECTION) {
  +            cur = cur->next;
  +        }
  +        r->output_filters = r->proto_output_filters = cur;
   
           bb = apr_brigade_create(r->pool);
           b = apr_bucket_pipe_create(tempsock);
  
  
  

Re: cvs commit: httpd-2.0/modules/generators mod_cgi.c mod_cgid.c

Posted by Jeff Trawick <tr...@attglobal.net>.
"Ryan Bloom" <rb...@covalent.net> writes:

> It's good to feel loved and appreciated.  :-)

;)

-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

RE: cvs commit: httpd-2.0/modules/generators mod_cgi.c mod_cgid.c

Posted by Ryan Bloom <rb...@covalent.net>.
From: trawick@rdu88-250-035.nc.rr.com [mailto:trawick@rdu88-250-
> Thom May <th...@planetarytramp.net> writes:
> 
> > OK, this is fixed in the current 2.0.34 tag - my apologies for the
wrong
> > diagnosis.
> 
> no apologies necessary...  frankly, I always blame Ryan for everything
> even if he is nowhere in sight...  if you want to blame me than that
> is only fair :)

It's good to feel loved and appreciated.  :-)

Ryan



Re: cvs commit: httpd-2.0/modules/generators mod_cgi.c mod_cgid.c

Posted by Jeff Trawick <tr...@attglobal.net>.
Thom May <th...@planetarytramp.net> writes:

> OK, this is fixed in the current 2.0.34 tag - my apologies for the wrong
> diagnosis.

no apologies necessary...  frankly, I always blame Ryan for everything
even if he is nowhere in sight...  if you want to blame me than that
is only fair :)

-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

Re: cvs commit: httpd-2.0/modules/generators mod_cgi.c mod_cgid.c

Posted by Thom May <th...@planetarytramp.net>.
* Jeff Trawick (trawick@attglobal.net) wrote :
> Thom May <th...@planetarytramp.net> writes:
> 
> > This change appears to have broken some cgі scripts - cricket
> > <http://cricket.sourceforge.net/> worked fine in 2.0.33 but in 2.0.34 and
> > 35-dev:
> > 
> > [Sat Mar 30 15:20:03 2002] [error] [client 192.168.0.34] malformed header
> > from 
: /usr/lib/cgi-bin/cricket/grapher.cgi
> > 
> > Cheers,
> > -Thom
> 
> I don't really see how.  The code executed was completely unchanged
> except when nph is set.  nph should only be set for a nph script --
> one that starts with nph-.
> 
> That message "malformed header" makes me wonder if a recent change to
> avoid reading one byte at a time broke it.  Look at Brian Pane's (I
> think it was him) recent commit to change the way we read headers from
> the CGI script.  Maybe there is a connection between that change and
> the breakage of your cgi.
> 
> If you have a simple example I'm willing to debug.
> 
OK, this is fixed in the current 2.0.34 tag - my apologies for the wrong
diagnosis.
-Thom

Re: cvs commit: httpd-2.0/modules/generators mod_cgi.c mod_cgid.c

Posted by Jeff Trawick <tr...@attglobal.net>.
Thom May <th...@planetarytramp.net> writes:

> This change appears to have broken some cgі scripts - cricket
> <http://cricket.sourceforge.net/> worked fine in 2.0.33 but in 2.0.34 and
> 35-dev:
> 
> [Sat Mar 30 15:20:03 2002] [error] [client 192.168.0.34] malformed header
> from 
: /usr/lib/cgi-bin/cricket/grapher.cgi
> 
> Cheers,
> -Thom

I don't really see how.  The code executed was completely unchanged
except when nph is set.  nph should only be set for a nph script --
one that starts with nph-.

That message "malformed header" makes me wonder if a recent change to
avoid reading one byte at a time broke it.  Look at Brian Pane's (I
think it was him) recent commit to change the way we read headers from
the CGI script.  Maybe there is a connection between that change and
the breakage of your cgi.

If you have a simple example I'm willing to debug.

> > trawick     02/03/20 05:57:08
> > 
> >   Modified:    .        CHANGES
> >                modules/generators mod_cgi.c mod_cgid.c
> >   Log:
> >   Get nph- CGI scripts working again by avoiding filters that can't
> >   possibly deal with a script that generates the protocol header.
> >   
> >   PR:       8902, 8907, 9983

-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

Re: cvs commit: httpd-2.0/modules/generators mod_cgi.c mod_cgid.c

Posted by Brian Havard <br...@kheldar.apana.org.au>.
On Sat, 30 Mar 2002 21:14:41 -0800, Brian Pane wrote:

>Brian Havard wrote:
>
>>On Sat, 30 Mar 2002 16:14:55 +0000, Thom May wrote:
>>
>>>This change appears to have broken some cgÑ  scripts - cricket
>>><http://cricket.sourceforge.net/> worked fine in 2.0.33 but in 2.0.34 and
>>>35-dev:
>>>
>>>[Sat Mar 30 15:20:03 2002] [error] [client 192.168.0.34] malformed header
>>>
>>>from 
>>: /usr/lib/cgi-bin/cricket/grapher.cgi
>>
>>I'm seeing something similar to this in recent code. This is from a virtual
>>include in an SSI:
>>
>>[Sun Mar 31 14:24:05 2002] [error] [client 202.12.87.82] malformed header
>>from script. Bad header=
>>: F:/Data/Web.Pages/Silk/cgi-bin/count, referer: http://kheldar/silk/
>>
>>Looking at the log file in a hex view the bad header appears to be a single
>>CR character, suggesting that CR/LF terminated lines are no longer accepted
>>from CGI scripts.
>>
>
>Yes, that's the problem.  I based getsfunc_BRIGADE() on the
>semantics of the apr_file_gets() call that it replaced--but
>the Unix version, which only checks for LF and not CR.  Your
>patch looks good.

Ok, I've just committed it.

-- 
 ______________________________________________________________________________
 |  Brian Havard                 |  "He is not the messiah!                   |
 |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of Brian |
 ------------------------------------------------------------------------------


Re: cvs commit: httpd-2.0/modules/generators mod_cgi.c mod_cgid.c

Posted by Brian Pane <br...@cnet.com>.
Brian Havard wrote:

>On Sat, 30 Mar 2002 16:14:55 +0000, Thom May wrote:
>
>>This change appears to have broken some cgÑ  scripts - cricket
>><http://cricket.sourceforge.net/> worked fine in 2.0.33 but in 2.0.34 and
>>35-dev:
>>
>>[Sat Mar 30 15:20:03 2002] [error] [client 192.168.0.34] malformed header
>>
>>from 
>: /usr/lib/cgi-bin/cricket/grapher.cgi
>
>I'm seeing something similar to this in recent code. This is from a virtual
>include in an SSI:
>
>[Sun Mar 31 14:24:05 2002] [error] [client 202.12.87.82] malformed header
>from script. Bad header=
>: F:/Data/Web.Pages/Silk/cgi-bin/count, referer: http://kheldar/silk/
>
>Looking at the log file in a hex view the bad header appears to be a single
>CR character, suggesting that CR/LF terminated lines are no longer accepted
>from CGI scripts.
>

Yes, that's the problem.  I based getsfunc_BRIGADE() on the
semantics of the apr_file_gets() call that it replaced--but
the Unix version, which only checks for LF and not CR.  Your
patch looks good.

Thanks,
--Brian



Re: cvs commit: httpd-2.0/modules/generators mod_cgi.c mod_cgid.c

Posted by Brian Havard <br...@kheldar.apana.org.au>.
On Sat, 30 Mar 2002 16:14:55 +0000, Thom May wrote:

>This change appears to have broken some cgÑ  scripts - cricket
><http://cricket.sourceforge.net/> worked fine in 2.0.33 but in 2.0.34 and
>35-dev:
>
>[Sat Mar 30 15:20:03 2002] [error] [client 192.168.0.34] malformed header
>from 
: /usr/lib/cgi-bin/cricket/grapher.cgi

I'm seeing something similar to this in recent code. This is from a virtual
include in an SSI:

[Sun Mar 31 14:24:05 2002] [error] [client 202.12.87.82] malformed header
from script. Bad header=
: F:/Data/Web.Pages/Silk/cgi-bin/count, referer: http://kheldar/silk/

Looking at the log file in a hex view the bad header appears to be a single
CR character, suggesting that CR/LF terminated lines are no longer accepted
from CGI scripts.

This fixes it for me, though may not be ideal:

Index: server/util_script.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/util_script.c,v
retrieving revision 1.75
diff -u -r1.75 util_script.c
--- server/util_script.c	2002/03/30 22:48:39	1.75
+++ server/util_script.c	2002/03/31 04:34:42
@@ -645,7 +645,7 @@
             if (*src == '\n') {
                 done = 1;
             }
-            else {
+            else if (*src != '\r') {
                 *dst++ = *src;
             }
             src++;

-- 
 ______________________________________________________________________________
 |  Brian Havard                 |  "He is not the messiah!                   |
 |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of Brian |
 ------------------------------------------------------------------------------


Re: cvs commit: httpd-2.0/modules/generators mod_cgi.c mod_cgid.c

Posted by Thom May <th...@planetarytramp.net>.
This change appears to have broken some cgі scripts - cricket
<http://cricket.sourceforge.net/> worked fine in 2.0.33 but in 2.0.34 and
35-dev:

[Sat Mar 30 15:20:03 2002] [error] [client 192.168.0.34] malformed header
from 
: /usr/lib/cgi-bin/cricket/grapher.cgi

Cheers,
-Thom

* trawick@apache.org (trawick@apache.org) wrote :
> trawick     02/03/20 05:57:08
> 
>   Modified:    .        CHANGES
>                modules/generators mod_cgi.c mod_cgid.c
>   Log:
>   Get nph- CGI scripts working again by avoiding filters that can't
>   possibly deal with a script that generates the protocol header.
>   
>   PR:       8902, 8907, 9983
>   
>   Revision  Changes    Path
>   1.648     +3 -0      httpd-2.0/CHANGES
>   
>   Index: CHANGES
>   ===================================================================
>   RCS file: /home/cvs/httpd-2.0/CHANGES,v
>   retrieving revision 1.647
>   retrieving revision 1.648
>   diff -u -r1.647 -r1.648
>   --- CHANGES	20 Mar 2002 07:10:21 -0000	1.647
>   +++ CHANGES	20 Mar 2002 13:57:07 -0000	1.648
>   @@ -1,5 +1,8 @@
>    Changes with Apache 2.0.34-dev
>    
>   +  *) Get nph- CGI scripts working again.  PRs 8902, 8907, 9983
>   +     [Jeff Trawick]
>   +
>      *) Upgraded PCRE library to latest version 3.9 [Brian Pane]
>    
>      *) Add accessor function to set r->content_type. From now on,
>   
>   
>   
>   1.123     +13 -0     httpd-2.0/modules/generators/mod_cgi.c
>   
>   Index: mod_cgi.c
>   ===================================================================
>   RCS file: /home/cvs/httpd-2.0/modules/generators/mod_cgi.c,v
>   retrieving revision 1.122
>   retrieving revision 1.123
>   diff -u -r1.122 -r1.123
>   --- mod_cgi.c	20 Mar 2002 01:58:46 -0000	1.122
>   +++ mod_cgi.c	20 Mar 2002 13:57:08 -0000	1.123
>   @@ -739,6 +739,19 @@
>        }
>    
>        if (script_in && nph) {
>   +        struct ap_filter_t *cur;
>   +        
>   +        /* get rid of all filters up through protocol...  since we
>   +         * haven't parsed off the headers, there is no way they can
>   +         * work
>   +         */
>   +
>   +        cur = r->proto_output_filters;
>   +        while (cur && cur->frec->ftype < AP_FTYPE_CONNECTION) {
>   +            cur = cur->next;
>   +        }
>   +        r->output_filters = r->proto_output_filters = cur;
>   +
>            bb = apr_brigade_create(r->pool);
>    	b = apr_bucket_pipe_create(script_in);
>    	APR_BRIGADE_INSERT_TAIL(bb, b);
>   
>   
>   
>   1.120     +13 -0     httpd-2.0/modules/generators/mod_cgid.c
>   
>   Index: mod_cgid.c
>   ===================================================================
>   RCS file: /home/cvs/httpd-2.0/modules/generators/mod_cgid.c,v
>   retrieving revision 1.119
>   retrieving revision 1.120
>   diff -u -r1.119 -r1.120
>   --- mod_cgid.c	20 Mar 2002 01:58:46 -0000	1.119
>   +++ mod_cgid.c	20 Mar 2002 13:57:08 -0000	1.120
>   @@ -1159,11 +1159,24 @@
>        } 
>    
>        if (nph) {
>   +        struct ap_filter_t *cur;
>   +        
>            /* Passing our socket down the filter chain in a pipe bucket
>             * gives up the responsibility of closing the socket, so
>             * get rid of the cleanup.
>             */
>            apr_pool_cleanup_kill(r->pool, (void *)sd, close_unix_socket);
>   +
>   +        /* get rid of all filters up through protocol...  since we
>   +         * haven't parsed off the headers, there is no way they can
>   +         * work
>   +         */
>   +
>   +        cur = r->proto_output_filters;
>   +        while (cur && cur->frec->ftype < AP_FTYPE_CONNECTION) {
>   +            cur = cur->next;
>   +        }
>   +        r->output_filters = r->proto_output_filters = cur;
>    
>            bb = apr_brigade_create(r->pool);
>            b = apr_bucket_pipe_create(tempsock);
>   
>   
>   

Re: cvs commit: httpd-2.0/modules/generators mod_cgi.c mod_cgid.c

Posted by Thom May <th...@planetarytramp.net>.
This change appears to have broken some cgі scripts - cricket
<http://cricket.sourceforge.net/> worked fine in 2.0.33 but in 2.0.34 and
35-dev:

[Sat Mar 30 15:20:03 2002] [error] [client 192.168.0.34] malformed header
from 
: /usr/lib/cgi-bin/cricket/grapher.cgi

Cheers,
-Thom

* trawick@apache.org (trawick@apache.org) wrote :
> trawick     02/03/20 05:57:08
> 
>   Modified:    .        CHANGES
>                modules/generators mod_cgi.c mod_cgid.c
>   Log:
>   Get nph- CGI scripts working again by avoiding filters that can't
>   possibly deal with a script that generates the protocol header.
>   
>   PR:       8902, 8907, 9983
>   
>   Revision  Changes    Path
>   1.648     +3 -0      httpd-2.0/CHANGES
>   
>   Index: CHANGES
>   ===================================================================
>   RCS file: /home/cvs/httpd-2.0/CHANGES,v
>   retrieving revision 1.647
>   retrieving revision 1.648
>   diff -u -r1.647 -r1.648
>   --- CHANGES	20 Mar 2002 07:10:21 -0000	1.647
>   +++ CHANGES	20 Mar 2002 13:57:07 -0000	1.648
>   @@ -1,5 +1,8 @@
>    Changes with Apache 2.0.34-dev
>    
>   +  *) Get nph- CGI scripts working again.  PRs 8902, 8907, 9983
>   +     [Jeff Trawick]
>   +
>      *) Upgraded PCRE library to latest version 3.9 [Brian Pane]
>    
>      *) Add accessor function to set r->content_type. From now on,
>   
>   
>   
>   1.123     +13 -0     httpd-2.0/modules/generators/mod_cgi.c
>   
>   Index: mod_cgi.c
>   ===================================================================
>   RCS file: /home/cvs/httpd-2.0/modules/generators/mod_cgi.c,v
>   retrieving revision 1.122
>   retrieving revision 1.123
>   diff -u -r1.122 -r1.123
>   --- mod_cgi.c	20 Mar 2002 01:58:46 -0000	1.122
>   +++ mod_cgi.c	20 Mar 2002 13:57:08 -0000	1.123
>   @@ -739,6 +739,19 @@
>        }
>    
>        if (script_in && nph) {
>   +        struct ap_filter_t *cur;
>   +        
>   +        /* get rid of all filters up through protocol...  since we
>   +         * haven't parsed off the headers, there is no way they can
>   +         * work
>   +         */
>   +
>   +        cur = r->proto_output_filters;
>   +        while (cur && cur->frec->ftype < AP_FTYPE_CONNECTION) {
>   +            cur = cur->next;
>   +        }
>   +        r->output_filters = r->proto_output_filters = cur;
>   +
>            bb = apr_brigade_create(r->pool);
>    	b = apr_bucket_pipe_create(script_in);
>    	APR_BRIGADE_INSERT_TAIL(bb, b);
>   
>   
>   
>   1.120     +13 -0     httpd-2.0/modules/generators/mod_cgid.c
>   
>   Index: mod_cgid.c
>   ===================================================================
>   RCS file: /home/cvs/httpd-2.0/modules/generators/mod_cgid.c,v
>   retrieving revision 1.119
>   retrieving revision 1.120
>   diff -u -r1.119 -r1.120
>   --- mod_cgid.c	20 Mar 2002 01:58:46 -0000	1.119
>   +++ mod_cgid.c	20 Mar 2002 13:57:08 -0000	1.120
>   @@ -1159,11 +1159,24 @@
>        } 
>    
>        if (nph) {
>   +        struct ap_filter_t *cur;
>   +        
>            /* Passing our socket down the filter chain in a pipe bucket
>             * gives up the responsibility of closing the socket, so
>             * get rid of the cleanup.
>             */
>            apr_pool_cleanup_kill(r->pool, (void *)sd, close_unix_socket);
>   +
>   +        /* get rid of all filters up through protocol...  since we
>   +         * haven't parsed off the headers, there is no way they can
>   +         * work
>   +         */
>   +
>   +        cur = r->proto_output_filters;
>   +        while (cur && cur->frec->ftype < AP_FTYPE_CONNECTION) {
>   +            cur = cur->next;
>   +        }
>   +        r->output_filters = r->proto_output_filters = cur;
>    
>            bb = apr_brigade_create(r->pool);
>            b = apr_bucket_pipe_create(tempsock);
>   
>   
>