glenn       02/04/09 06:29:37

  Modified:    catalina/src/share/org/apache/catalina/connector Tag:
                        tomcat_40_branch HttpRequestBase.java
                        LocalStrings.properties
  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
  No                   revision
  
  
  No                   revision
  
  
  1.31.2.4  +22 -8     
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.31.2.3
  retrieving revision 1.31.2.4
  diff -u -r1.31.2.3 -r1.31.2.4
  --- HttpRequestBase.java      6 Apr 2002 03:07:03 -0000       1.31.2.3
  +++ HttpRequestBase.java      9 Apr 2002 13:29:37 -0000       1.31.2.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpRequestBase.java,v
 1.31.2.3 2002/04/06 03:07:03 remm Exp $
  - * $Revision: 1.31.2.3 $
  - * $Date: 2002/04/06 03:07:03 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/HttpRequestBase.java,v
 1.31.2.4 2002/04/09 13:29:37 glenn Exp $
  + * $Revision: 1.31.2.4 $
  + * $Date: 2002/04/09 13:29:37 $
    *
    * ====================================================================
    *
  @@ -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.31.2.3 $ $Date: 2002/04/06 03:07:03 $
  + * @version $Revision: 1.31.2.4 $ $Date: 2002/04/09 13:29:37 $
    */
   
   public class HttpRequestBase
  @@ -622,7 +623,8 @@
           String queryString = getQueryString();
           try {
               RequestUtil.parseParameters(results, queryString, encoding);
  -        } catch (Throwable t) {
  +        } catch (UnsupportedEncodingException e) {
  +            ;
           }
   
           // Parse any parameters specified in the input stream
  @@ -638,6 +640,7 @@
           if ("POST".equals(getMethod()) && (getContentLength() > 0)
               && (this.stream == null)
               && "application/x-www-form-urlencoded".equals(contentType)) {
  +
               try {
                   int max = getContentLength();
                   int len = 0;
  @@ -645,13 +648,24 @@
                   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());
  +             }
           }
   
           // Store the final results
  
  
  
  1.5.2.1   +2 -0      
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- LocalStrings.properties   25 Jul 2001 04:27:29 -0000      1.5
  +++ LocalStrings.properties   9 Apr 2002 13:29:37 -0000       1.5.2.1
  @@ -1,4 +1,6 @@
   httpRequestBase.createCommitted=Cannot create a session after the response has been 
committed
  +httpRequestBase.contentLengthMismatch=Read of HTTP Request POST parameters failed: 
read < content length
  +httpRequestBase.contentReadFail=Read of HTTP Request POST parameters failed: 
   httpResponseBase.sendError.ise=Cannot call sendError() after the response has been 
committed
   httpResponseBase.sendRedirect.ise=Cannot call sendRedirect() after the response has 
been committed
   requestBase.getInputStream.ise=getReader() has already been called for this request
  
  
  

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

Reply via email to