possible httpd applet bug?

Denis Vlasenko vda.linux at googlemail.com
Wed Jan 3 03:30:12 UTC 2007


On Tuesday 02 January 2007 16:15, Paul Albrecht wrote:
> 
> I have a question about the way the busybox httpd applet reads cgi
> program output: Why is safe_read used rather than full_read?
> 
> The problem with safe_read is you're not guaranteed the entire first
> line of cgi output on the first read so the applet doesn't handle the
> status line or content-type header correctly.
> 
> Seems like if you don't want to read all the cgi output at once, then
> you should buffer the first line, but I don't think it makes much of a
> difference for busybox httpd.

This code?

                if (FD_ISSET(inFd, &readSet)) {
                        int s = config->accepted_socket;
                        char *rbuf = config->buf;

#ifndef PIPE_BUF
# define PIPESIZE 4096          /* amount of buffering in a pipe */
#else
# define PIPESIZE PIPE_BUF
#endif
#if PIPESIZE >= MAX_MEMORY_BUFF
# error "PIPESIZE >= MAX_MEMORY_BUFF"
#endif

                        /* There is something to read */
                        count = safe_read(inFd, rbuf, PIPESIZE);

What will happen if there is less than PIPESIZE bytes? Hmm...
if child has died, we will get short read anyway;
if it has paused, we will block on this read... is it bad? why?

(btw, I read around that place. What kind of English is this
variable name - post_readed_xxx? I think it's vodz contribution...)

Need to think about it a bit more.

Suggestions in the form of patches are always welcome. ;)
--
vda



More information about the busybox mailing list