Must really be safe_read(), not full_read()? (was: [PATCH] fix httpd lockup in cgi POSTs)

Denis Vlasenko vda.linux at googlemail.com
Mon Feb 12 20:52:29 UTC 2007


On Monday 12 February 2007 16:25, Paul Albrecht wrote:
> 
> Reverting the code back to using safe_read doesn't work if you don't fix
> the way the first line is handled because you're not guaranteed a full
> line with the safe_read.
> 
> You can verify this by writing a cgi program which redirects to another
> location.

Testcase, please?

> It will intermittently fail. This has nothing to do with how the cgi
> program writes to standard output. It's a consequence of the fact that
> the server doesn't buffer standard input so it has no right to expect a
> full line with its first read of cgi output.

We don't care about first line. We care about first four charachers only,
I think.

> An expedient way to fix the problem is to do the full_read, that is,
> receive all the cgi output before handling the first line.
> 
> If this is not sufficient then busybox httpd should line buffer standard
> input so that it always handles the status line correctly. 

Yes, this will even handle the case when CGI writes "HTT" and
"P/1.0 200 OK" separately.
--
vda



More information about the busybox mailing list