From 327d811b3d137d6fe17194942ae366428a2c468b Mon Sep 17 00:00:00 2001 From: Greg Ames Date: Thu, 5 Oct 2000 03:55:12 +0000 Subject: [PATCH] Fix a bug where a client which only sends \n to delimit header 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 | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 3d3cb942ce..8200422256 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -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); } -- 2.40.0