httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject cvs commit: apache-1.3/src/modules/proxy proxy_util.c
Date Mon, 17 Jun 2002 18:14:13 GMT
jim         2002/06/17 11:14:12

  Modified:    src/main http_protocol.c
               src/modules/proxy proxy_util.c
  Log:
  Backport of 2.0 chunk handling
  Submitted by:	Justin
  Reviewed by:	Aaron, Cliff, Jim
  
  Revision  Changes    Path
  1.317     +22 -5     apache-1.3/src/main/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/main/http_protocol.c,v
  retrieving revision 1.316
  retrieving revision 1.317
  diff -u -r1.316 -r1.317
  --- http_protocol.c	29 May 2002 08:52:20 -0000	1.316
  +++ http_protocol.c	17 Jun 2002 18:14:12 -0000	1.317
  @@ -2045,21 +2045,34 @@
   API_EXPORT(long) ap_get_chunk_size(char *b)
   {
       long chunksize = 0;
  +    long chunkbits = sizeof(long) * 8;
   
  -    while (ap_isxdigit(*b)) {
  +    /* Skip leading zeros */
  +    while (*b == '0') {
  +        ++b;
  +    }
  +
  +    while (ap_isxdigit(*b) && (chunkbits > 0)) {
           int xvalue = 0;
   
  -	/* This works even on EBCDIC. */
  -        if (*b >= '0' && *b <= '9')
  +        if (*b >= '0' && *b <= '9') {
               xvalue = *b - '0';
  -        else if (*b >= 'A' && *b <= 'F')
  +        }
  +        else if (*b >= 'A' && *b <= 'F') {
               xvalue = *b - 'A' + 0xa;
  -        else if (*b >= 'a' && *b <= 'f')
  +        }
  +        else if (*b >= 'a' && *b <= 'f') {
               xvalue = *b - 'a' + 0xa;
  +        }
   
           chunksize = (chunksize << 4) | xvalue;
  +        chunkbits -= 4;
           ++b;
       }
  +    if (ap_isxdigit(*b) && (chunkbits <= 0)) {
  +        /* overflow */
  +        return -1;
  +    }
   
       return chunksize;
   }
  @@ -2143,6 +2156,10 @@
                   return 0;
               }
               r->remaining = -1;  /* Indicate footers in-progress */
  +        }
  +        else if (len_to_read < 0) {
  +            r->connection->keepalive = -1;
  +            return -1;
           }
           else {
               r->remaining = len_to_read;
  
  
  
  1.124     +6 -0      apache-1.3/src/modules/proxy/proxy_util.c
  
  Index: proxy_util.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/modules/proxy/proxy_util.c,v
  retrieving revision 1.123
  retrieving revision 1.124
  diff -u -r1.123 -r1.124
  --- proxy_util.c	17 Jun 2002 17:58:43 -0000	1.123
  +++ proxy_util.c	17 Jun 2002 18:14:12 -0000	1.124
  @@ -539,6 +539,12 @@
                               n = -1;
                           }
                       }
  +                    else if (remaining < 0) {
  +                        n = -1;
  +                        ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r,
  +                                      "proxy: remote protocol error, invalid chunk size");
  +
  +                    }
                   }
               }
   
  
  
  

Mime
View raw message