1 diff -urN httpd-2.0.52.org/server/protocol.c httpd-2.0.52/server/protocol.c
2 --- httpd-2.0.52.org/server/protocol.c 15 Sep 2004 10:47:56 -0000 1.121.2.20
3 +++ httpd-2.0.52.org/server/protocol.c 10 Nov 2004 11:32:40 -0000 1.121.2.22
5 if (n < bytes_handled + len) {
8 - /* ensure this string is terminated */
9 - if (bytes_handled < n) {
10 + /* ensure this string is NUL terminated */
11 + if (bytes_handled > 0) {
12 (*s)[bytes_handled-1] = '\0';
24 - /* We now go backwards over any CR (if present) or white spaces.
26 - * Trim any extra trailing spaces or tabs except for the first
27 - * space or tab at the beginning of a blank string. This makes
28 - * it much easier to check field values for exact matches, and
29 - * saves memory as well. Terminate string at end of line.
32 - if (pos > *s && *(pos - 1) == APR_ASCII_CR) {
36 - /* Trim any extra trailing spaces or tabs except for the first
37 - * space or tab at the beginning of a blank string. This makes
38 - * it much easier to check field values for exact matches, and
39 - * saves memory as well.
41 - while (pos > ((*s) + 1)
42 - && (*(pos - 1) == APR_ASCII_BLANK || *(pos - 1) == APR_ASCII_TAB)) {
44 + /* Now NUL-terminate the string at the end of the line;
45 + * if the last-but-one character is a CR, terminate there */
46 + if (last_char > *s && last_char[-1] == APR_ASCII_CR) {
50 - /* Since we want to remove the LF from the line, we'll go ahead
51 - * and set this last character to be the term NULL and reset
52 - * bytes_handled accordingly.
56 - bytes_handled = pos - *s;
58 + bytes_handled = last_char - *s;
60 /* If we're folding, we have more work to do.
67 + else /* not a continuation line */ {
69 if (r->server->limit_req_fields
70 && (++fields_read > r->server->limit_req_fields)) {
76 + tmp_field = value - 1; /* last character of field-name */
78 + *value++ = '\0'; /* NUL-terminate at colon */
81 - tmp_field = value; /* used to trim the whitespace between key
82 - * token and separator
85 while (*value == ' ' || *value == '\t') {
86 ++value; /* Skip to start of value */
89 - /* This check is to avoid any invalid memory reference while
90 - * traversing backwards in the key. To avoid a case where
91 - * the header starts with ':' (or with just some white
92 - * space and the ':') followed by the value
94 - if (tmp_field > last_field) {
96 - while ((tmp_field > last_field) &&
97 - (*tmp_field == ' ' || *tmp_field == '\t')) {
98 - --tmp_field; /* Removing LWS between key and ':' */
102 + /* Strip LWS after field-name: */
103 + while (tmp_field > last_field
104 + && (*tmp_field == ' ' || *tmp_field == '\t')) {
105 + *tmp_field-- = '\0';
108 + /* Strip LWS after field-value: */
109 + tmp_field = last_field + last_len - 1;
110 + while (tmp_field > value
111 + && (*tmp_field == ' ' || *tmp_field == '\t')) {
112 + *tmp_field-- = '\0';
115 apr_table_addn(r->headers_in, last_field, value);