glenn       02/04/09 05:53:45

  Modified:    catalina/src/share/org/apache/catalina/connector
                        HttpRequestBase.java
  Log:
  Fix for a bug where parseParameters() could go into an infinite loop
  trying to read the HTTP Request POST content if the content sent was
  less than the content length. If this happens an unchecked RuntimeException()
  is thrown.  This bug was seen using mod_jk and Ajp13.
  
  Throw the unchecked RuntimeException() if there is an IOException.
  Previously IOExceptions had been ignored, the request should fail
  if there was an IOException.
  
  Revision  Changes    Path
  1.38      +20 -6     
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpRequestBase.java
  
  Index: HttpRequestBase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpRequestBase.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- HttpRequestBase.java      6 Apr 2002 03:06:52 -0000       1.37
  +++ HttpRequestBase.java      9 Apr 2002 12:53:45 -0000       1.38
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpRequestBase.java,v
 1.37 2002/04/06 03:06:52 remm Exp $
  - * $Revision: 1.37 $
  - * $Date: 2002/04/06 03:06:52 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpRequestBase.java,v
 1.38 2002/04/09 12:53:45 glenn Exp $
  + * $Revision: 1.38 $
  + * $Date: 2002/04/09 12:53:45 $
    *
    * ====================================================================
    *
  @@ -66,6 +66,7 @@
   
   
   import java.io.IOException;
  +import java.io.UnsupportedEncodingException;
   import java.security.AccessController;
   import java.security.Principal;
   import java.security.PrivilegedAction;
  @@ -102,7 +103,7 @@
    * be implemented.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.37 $ $Date: 2002/04/06 03:06:52 $
  + * @version $Revision: 1.38 $ $Date: 2002/04/09 12:53:45 $
    * @deprecated
    */
   
  @@ -630,7 +631,8 @@
           String queryString = getQueryString();
           try {
               RequestUtil.parseParameters(results, queryString, encoding);
  -        } catch (Throwable t) {
  +        } catch (UnsupportedEncodingException e) {
  +            ;
           }
   
           // Parse any parameters specified in the input stream
  @@ -646,6 +648,7 @@
           if ("POST".equals(getMethod()) && (getContentLength() > 0)
               && (this.stream == null)
               && "application/x-www-form-urlencoded".equals(contentType)) {
  +
               try {
                   int max = getContentLength();
                   int len = 0;
  @@ -653,12 +656,23 @@
                   ServletInputStream is = getInputStream();
                   while (len < max) {
                       int next = is.read(buf, len, max - len);
  +                    if (next < 0 ) {
  +                        break;
  +                    }
                       len += next;
                   }
                   is.close();
  +                if (len < max) {
  +                    throw new RuntimeException
  +                        (sm.getString("httpRequestBase.contentLengthMismatch"));
  +                }
                   RequestUtil.parseParameters(results, buf, encoding);
  -            } catch (Throwable t) {
  +            } catch (UnsupportedEncodingException ue) {
                   ;
  +            } catch (IOException e) {
  +                throw new RuntimeException
  +                        (sm.getString("httpRequestBase.contentReadFail") + 
  +                         e.getMessage());
               }
           }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to