I was lying in bed this morning and suddenly realised that I'd strcpy'd when I should have strncpy'd && terminated in that patch I sent out yesterday. *slaps forehead*.
So *DON'T* use the patch I sent out yesterday! Here is one that has been corrected...


Cheers, Brett

diff -Naur old/proxy_util.c new/proxy_util.c
--- old/proxy_util.c    Fri Aug 16 10:16:56 2002
+++ new/proxy_util.c    Sat Aug 17 08:20:28 2002
@@ -377,12 +377,23 @@
  * headers, which contain commas within the date field) do not get stuffed
  * up.
  */
+static struct field_allowing_additional_lines {
+    char *field_name;
+    unsigned short max_num_additional_lines;
+} fields_allowing_additional_lines[] = {
+       { "Server", 2 } /* allow the server field a max of 2 additional lines */
+};
+
 table *ap_proxy_read_headers(request_rec *r, char *buffer, int size, BUFF *f)
 {
     table *resp_hdrs;
     int len;
     char *value, *end;
     char field[MAX_STRING_LEN];
+    char field_name[MAX_STRING_LEN]; /* to store the last field name read */
+       int num_additional_lines = 0; /* to count the number of crap header 
lines */
+
+    field_name[0] = '\0';
 
     resp_hdrs = ap_make_table(r->pool, 20);
 
@@ -391,8 +402,33 @@
      * the connection closes (EOF), or we timeout.
      */
     while ((len = ap_getline(buffer, size, f, 1)) > 0) {
-
         if (!(value = strchr(buffer, ':'))) {   /* Find the colon separator */
+                       /* check to see if the last header field read is
+                          one we can have continuation lines for...
+                       */
+                       if (field_name[0]) /* check the 1st byte for null to be 
quick */
+                       {
+                               int i = 0;
+                               int i_max = 
sizeof(fields_allowing_additional_lines) / sizeof(struct 
field_allowing_additional_lines);
+                               int ok_to_continue = 0;
+
+                               while (i < i_max)
+                               {
+                                       if (!strcmp(field_name, 
fields_allowing_additional_lines[i].field_name))
+                                       {
+                                               if (num_additional_lines < 
fields_allowing_additional_lines[i].max_num_additional_lines)
+                                                       ok_to_continue = 1;
+                                               break;
+                                       }
+                                       i++;
+                               }
+
+                               if (ok_to_continue)
+                               {
+                                       num_additional_lines++;
+                                       continue;
+                               }
+                       }
 
             /*
              * Buggy MS IIS servers sometimes return invalid headers (an
@@ -415,6 +451,13 @@
 
         *value = '\0';
         ++value;
+
+               /* woo hoo! We got a new header! Do some stuff! */
+               /* copy the header field name into a buffer so we can check it 
later */
+               strncpy(field_name, buffer, MAX_STRING_LEN);
+               field_name[MAX_STRING_LEN-1] = '\0'; /* terminate potentially 
large strings */
+               num_additional_lines = 0; /* reset the number of additional 
lines */
+
         /*
          * XXX: RFC2068 defines only SP and HT as whitespace, this test is
          * wrong... and so are many others probably.

Reply via email to