]> git.pld-linux.org Git - packages/apache.git/blob - apache-CAN-2004-0942.patch
- http://issues.apache.org/bugzilla/show_bug.cgi?id=27550
[packages/apache.git] / apache-CAN-2004-0942.patch
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
4 @@ -251,12 +251,12 @@
5          if (n < bytes_handled + len) {
6              *read = bytes_handled;
7              if (*s) {
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';
13                  }
14                  else {
15 -                    (*s)[n-1] = '\0';
16 +                    (*s)[0] = '\0';
17                  }
18              }
19              return APR_ENOSPC;
20 @@ -305,35 +305,13 @@
21          }
22      }
23  
24 -    /* We now go backwards over any CR (if present) or white spaces.
25 -     *
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.
30 -     */
31 -    pos = last_char;
32 -    if (pos > *s && *(pos - 1) == APR_ASCII_CR) {
33 -        --pos;
34 -    }
35 -
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.
40 -     */
41 -    while (pos > ((*s) + 1)
42 -           && (*(pos - 1) == APR_ASCII_BLANK || *(pos - 1) == APR_ASCII_TAB)) {
43 -        --pos;
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) {
47 +        last_char--;
48      }
49 -
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.
53 -     */
54 -    *pos = '\0';
55 -    last_char = pos;
56 -    bytes_handled = pos - *s;
57 +    *last_char = '\0';
58 +    bytes_handled = last_char - *s;
59  
60      /* If we're folding, we have more work to do.
61       *
62 @@ -750,7 +728,7 @@
63                  last_len += len;
64                  folded = 1;
65              }
66 -            else {
67 +            else /* not a continuation line */ {
68  
69                  if (r->server->limit_req_fields
70                      && (++fields_read > r->server->limit_req_fields)) {
71 @@ -773,29 +751,26 @@
72                                                 "</pre>\n", NULL));
73                      return;
74                  }
75 +                
76 +                tmp_field = value - 1; /* last character of field-name */
77 +
78 +                *value++ = '\0'; /* NUL-terminate at colon */
79  
80 -                *value = '\0';
81 -                tmp_field = value;  /* used to trim the whitespace between key
82 -                                     * token and separator
83 -                                     */
84 -                ++value;
85                  while (*value == ' ' || *value == '\t') {
86                      ++value;            /* Skip to start of value   */
87                  }
88  
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
93 -                 */
94 -                if (tmp_field > last_field) {
95 -                    --tmp_field;
96 -                    while ((tmp_field > last_field) &&
97 -                           (*tmp_field == ' ' || *tmp_field == '\t')) {
98 -                        --tmp_field;   /* Removing LWS between key and ':' */
99 -                    }
100 -                    ++tmp_field;
101 -                    *tmp_field = '\0';
102 +                /* Strip LWS after field-name: */
103 +                while (tmp_field > last_field 
104 +                       && (*tmp_field == ' ' || *tmp_field == '\t')) {
105 +                    *tmp_field-- = '\0';
106 +                }
107 +                
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';
113                  }
114  
115                  apr_table_addn(r->headers_in, last_field, value);
This page took 0.040489 seconds and 3 git commands to generate.