httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@ast.cam.ac.uk (David Robinson)
Subject Re: change LF to CRLF ?
Date Tue, 21 Mar 1995 14:34:00 GMT
On Mon, 20 Mar 95 16:54:09 MST, Rob Hartill wrote:
> The offending bit of code wasn't in stream.c, it was in
> scan_script_header()
>
>        if (p > 0 && w[p-1] == '\n')
>        {
>            if (p > 1 && w[p-2] == '\015') w[p-2] = '\0'; 
>            else w[p-1] = '\0';
>        }
>        if(w[0] == '\0') return is_url(location);
>
>
>should be,
>
>        if (p > 0 && w[p-1] == LF)
>            w[p-1] = '\0';
>
>        if(!w[0] || (p>0 && w[0] == CR && !w[1])) return is_url(location);
>
>I suppose. 

Sorry, Rob, no. There was nothing wrong with that code. You are assuming
that the CGI script will return CRLF terminated headers. This assumption
will be wrong for the vast majority of CGI scripts.

The correct fix is to change scan_script_headers() futher down, where it
appends the CGI header to its list:
            *(--l) = ':';
            for(p=0;w[p];p++);
            w[p] = LF;
            w[++p] = '\0';
should be
            *(--l) = ':';
            p = strlen(w);
            w[p] = CR;
            w[++p] = LF;
            w[++p] = '\0';

You might also want to consider fixing this bug in scan_script_headers()
(w contains the header from the CGI script)
        if(!(l = strchr(w,':')))
            l = w;
        *l++ = '\0';
...
            *(--l) = ':';

Thus you get very strange output from 'headers' which do not contain a ':'.

> If you'd stuck to the CR LF syntax you dislike, it would have been easier
> to locate :-)

Fair comment.

 David.

Mime
View raw message