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

Matthias Reichl hias at horus.com
Mon Feb 12 17:09:59 UTC 2007


On Mon, Feb 12, 2007 at 10:25:09AM -0500, 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.

ACK, you are right.

> 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. 

If I understand the code correctly, it would be sufficient to do
something like

if (firstline)
    count = full_read(inFd, rbuf, 4);
    /* read 4 bytes so we can check if the line begins with "HTTP" */
} else {
    count = safe_read(inFd, rbuf, PIPESIZE);
}

Better yet, do a full line read for the first line or completely
switch to line buffered input, as you suggested.

so long,

Hias



More information about the busybox mailing list