]> granicus.if.org Git - apache/commitdiff
Fix a bug where a client which only sends \n to delimit header
authorGreg Ames <gregames@apache.org>
Thu, 5 Oct 2000 03:55:12 +0000 (03:55 +0000)
committerGreg Ames <gregames@apache.org>
Thu, 5 Oct 2000 03:55:12 +0000 (03:55 +0000)
lines (netcat) gets a strange looking HTTP_NOT_IMPLEMENTED message.

While I'm in there, start working on ebcdic co-existance with input
filtering.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86397 13f79535-47bb-0310-9956-ffa450edef68

modules/http/http_protocol.c

index 3d3cb942cebaf76c3e4f7a6cbd0cee389637478a..82004222564c0b82a66c617ae5fabcb1760de6ba 100644 (file)
@@ -890,6 +890,10 @@ static int getline(char *s, int n, conn_rec *c, int fold)
     int length;
     ap_bucket_brigade *b;
     ap_bucket *e;
+    
+#define ASCII_CR '\015'
+#define ASCII_LF '\012'
+    
 #ifdef APACHE_XLATE_XXX
     /* When getline() is called, the HTTP protocol is in a state
      * where we MUST be reading "plain text" protocol stuff,
@@ -940,12 +944,23 @@ static int getline(char *s, int n, conn_rec *c, int fold)
             break;
         }
 
-        if ((toss = ap_strchr_c(temp, '\r')) != NULL) { 
-            length = toss - temp + 2;
+       /* check for line end using ascii encoding, even on an ebcdic box
+        * since this is raw protocol data fresh from the network
+        */
+        if ((toss = ap_strchr_c(temp, ASCII_LF)) != NULL) { 
+            length = toss - temp + 1;
             e->split(e, length);
-            apr_cpystrn(pos, temp, length);
-            pos[length - 2] = '\n';
-            pos[--length] = '\0';
+            apr_cpystrn(pos, temp, length + 1);
+           
+           /* get rid of optional \r, again using ascii encoding */
+           
+           /*** XXX need 2 sentinels in front of pos 
+            ***     which are never ASCII_CR, in case length < 2
+            */
+           if (pos[length - 2] == ASCII_CR) {
+                pos[length - 2] = ASCII_LF;
+                pos[--length] = '\0';
+           }
             AP_BUCKET_REMOVE(e);
             e->destroy(e);
         }