[BusyBox-cvs] CVS update of busybox/networking (httpd.c)

Erik Andersen andersen at codepoet.org
Thu Aug 26 22:22:51 UTC 2004


    Date: Thursday, August 26, 2004 @ 16:22:51
  Author: andersen
    Path: /var/cvs/busybox/networking

Modified: httpd.c (1.26 -> 1.27)

Vladimir N. Oleynik writes:

Ming-Ching,

>>No. Here there are no mistakes.
>>You using POST metod.
>>For get data you should read from stdin CONTENT_LENGTH bytes.

>Hower as I posted a little while ago, there is indeed a bug
>in POST method if the CONTENT_LENGTH is bigger
>than sizeof(wbuf[128]). So if your CGI script is expecting to
>read the full CONTENT_LENGTH, it might block forever,
>because it will only transfer sizeof(wbuf) to the CGI.

Ok, Ok. I should find time to understand with a problem.
Try attached patch.


--w
vodz


Index: busybox/networking/httpd.c
diff -u busybox/networking/httpd.c:1.26 busybox/networking/httpd.c:1.27
--- busybox/networking/httpd.c:1.26	Wed Apr 14 11:51:24 2004
+++ busybox/networking/httpd.c	Thu Aug 26 16:22:50 2004
@@ -62,11 +62,11 @@
  * The Deny/Allow IP logic:
  *
  *  - Default is to allow all.  No addresses are denied unless
- * 	   denied with a D: rule.
+ *         denied with a D: rule.
  *  - Order of Deny/Allow rules is significant
  *  - Deny rules take precedence over allow rules.
  *  - If a deny all rule (D:*) is used it acts as a catch-all for unmatched
- * 	 addresses.
+ *       addresses.
  *  - Specification of Allow all (A:*) is a no-op
  *
  * Example:
@@ -1244,19 +1244,29 @@
 		}
       } else if(bodyLen > 0 && post_readed_size == 0 && FD_ISSET(a_c_r, &readSet)) {
 		count = bodyLen > sizeof(wbuf) ? sizeof(wbuf) : bodyLen;
-		count = bb_full_read(a_c_r, wbuf, count);
+		count = safe_read(a_c_r, wbuf, count);
 		if(count > 0) {
 			post_readed_size += count;
 			bodyLen -= count;
       } else {
 			bodyLen = 0;    /* closed */
 		}
-      } else if(FD_ISSET(inFd, &readSet)) {
+      }
+      if(FD_ISSET(inFd, &readSet)) {
 	int s = a_c_w;
 	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 = bb_full_read(inFd, rbuf, MAX_MEMORY_BUFF-1);
+	count = safe_read(inFd, rbuf, PIPESIZE);
 	if (count == 0)
 		break;  /* closed */
 	if (count > 0) {



More information about the busybox-cvs mailing list