Problem with httpd and POST data for cgi, and patch
Denys Vlasenko
vda.linux at googlemail.com
Sun Oct 14 02:21:39 UTC 2007
On Friday 12 October 2007 17:57, Ralf Friedl wrote:
> Hi
>
> I just found out that my previous patch only works for POST data smaller
> that hdr_buf. This patch should also work for larger POST data.
Thanks for the patch!
> --- networking/httpd.c
> +++ networking/httpd.c
> @@ -1051,6 +1051,10 @@
> * and send it to the peer. So please no SIGPIPEs! */
> signal(SIGPIPE, SIG_IGN);
>
> + if (post_len >= hdr_cnt)
> + post_len -= hdr_cnt;
> + else
> + post_len = 0;
> /* NB: breaking out of this loop jumps to log_and_exit() */
> out_cnt = 0;
> while (1) {
I propose just doing
post_len -= hdr_cnt;
instead of that if(). If post_len will get negative, this code
will catch that and will close CGI's input fd:
if (toCgi_wr) {
pfd[TO_CGI].fd = toCgi_wr;
if (hdr_cnt > 0) {
pfd[TO_CGI].events = POLLOUT;
} else if (post_len > 0) {
pfd[0].events = POLLIN;
} else {
/* post_len <= 0 && hdr_cnt <= 0:
* no more POST data to CGI,
* let CGI see EOF on CGI's stdin */
==========> close(toCgi_wr);
toCgi_wr = 0;
}
}
What do you think?
--
vda
More information about the busybox
mailing list