From: Ryan Bloom Date: Wed, 11 Oct 2000 18:32:19 +0000 (+0000) Subject: Cleanup the input filtering a bit. This does not work with telnet X-Git-Tag: APACHE_2_0_ALPHA_8~401 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3c11b9990cb220fbebefba1442a0632aff01e4d4;p=apache Cleanup the input filtering a bit. This does not work with telnet currently, but it is a step in the right direction. Input filtering should be slowly improving from here on out. Submitted by: Greg Ames, Ryan Bloom, Jeff Trawick git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86547 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http/http_core.c b/modules/http/http_core.c index cebf978d4e..e309a74d04 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -3305,37 +3305,15 @@ static apr_status_t chunk_filter(ap_filter_t *f, ap_bucket_brigade *b) static int core_input_filter(ap_filter_t *f, ap_bucket_brigade *b) { - char *buff; - apr_ssize_t length = HUGE_STRING_LEN; apr_socket_t *csock = NULL; - apr_status_t rv; ap_bucket *e; - /* As soon as we have pool buckets, this should become a palloc. */ - buff = apr_palloc(f->c->pool, HUGE_STRING_LEN); ap_bpop_socket(&csock, f->c->client); - - rv = apr_recv(csock, buff, &length); - if (rv == APR_SUCCESS) { - if (length > 0) { - /* This should probably be a pool bucket, but using a transient is - * actually okay here too. We know the pool we are using will always - * be available as long as the connection is open. - */ - e = ap_bucket_create_transient(buff, length); - AP_BRIGADE_INSERT_TAIL(b, e); - } - else { - /* XXX need to trigger EOS/EOF processing; - * for now, return empty brigade because that is what - * getline() looks for */ - } - } - else { - return rv; - } + e = ap_bucket_create_socket(csock); + AP_BRIGADE_INSERT_TAIL(b, e); return APR_SUCCESS; } + /* Default filter. This filter should almost always be used. Its only job * is to send the headers if they haven't already been sent, and then send * the actual data. diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 9d7b51f608..34117a2d89 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -868,7 +868,6 @@ apr_status_t http_filter(ap_filter_t *f, ap_bucket_brigade *b) char *buff; apr_ssize_t length; char *pos; - int state = 0; http_ctx_t *ctx = f->ctx; ap_bucket_brigade *bb; apr_status_t rv; @@ -921,30 +920,19 @@ apr_status_t http_filter(ap_filter_t *f, ap_bucket_brigade *b) return rv; } - pos = buff + 1; + pos = buff; while (pos < buff + length) { - - /* We are at the start of one line, but it actually has data. */ - if ((*pos != ASCII_LF) && (*pos != ASCII_CR)) { - state = 0; - } - else { - if (*pos == ASCII_LF) { - state++; + if (*pos == ASCII_LF) { + if (*(pos - 1) == ASCII_CR) { + *(pos - 1) = ASCII_LF; + *pos = '\0'; } - } - - if ((*pos == ASCII_LF) && (*(pos - 1) == ASCII_CR)) { - *(pos - 1) = ASCII_LF; - *pos = '\0'; - } - pos++; - if (state == 2) { - e->split(e, pos - buff); + e->split(e, pos - buff + (*pos == '\0')); bb = ap_brigade_split(b, AP_BUCKET_NEXT(e)); ctx->b = bb; return APR_SUCCESS; } + pos++; } } return APR_SUCCESS; @@ -1003,8 +991,8 @@ static int getline(char *s, int n, conn_rec *c, int fold) if (AP_BRIGADE_EMPTY(b)) { return -1; } - e = AP_BRIGADE_FIRST(b); while (1) { + e = AP_BRIGADE_FIRST(b); while (e->length == 0) { AP_BUCKET_REMOVE(e); ap_bucket_destroy(e); @@ -1028,14 +1016,26 @@ static int getline(char *s, int n, conn_rec *c, int fold) /* check for line end using ascii encoding, even on an ebcdic box * since this is raw protocol data fresh from the network */ +/*XXX This needs to be scrubbed, but Greg Ames is going to do a lot to this + * code in a little while. When he is done, it shouldn't need scrubbing + * any more. + * + * GREG, this is where the breakage is!!!! + */ if ((toss = ap_strchr_c(temp, ASCII_LF)) != NULL) { - length = toss - temp + 1; - e->split(e, length + (temp[length] == '\0')); + length = (toss - temp) + (pos - s) + 1; + e->split(e, length + (temp[length] == '\0')); apr_cpystrn(pos, temp, length + 1); - AP_BUCKET_REMOVE(e); ap_bucket_destroy(e); } + else { + apr_cpystrn(pos, temp, length + 1); + pos += length; + AP_BUCKET_REMOVE(e); + ap_bucket_destroy(e); + continue; + } c->input_data = b; e = AP_BRIGADE_FIRST(b); /**** XXX