You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@ws.apache.org by gd...@locus.apache.org on 2000/10/23 21:09:45 UTC

cvs commit: xml-soap/java/src/org/apache/soap/server/http ServerHTTPUtils.java

gdaniels    00/10/23 12:09:44

  Modified:    java/src/org/apache/soap/server/http ServerHTTPUtils.java
  Log:
  Fix from Chris Nelson:
  "I uncovered a rather nasty little bug in ServerHTTPUtils.  If a request is
  sent where Content-length specifies a length greater than the actual number
  of bytes sent, it will sit in an infinite loop trying to retrieve the
  non-existent extra bytes.  A simple check to make sure we are not at the end
  of the stream is all that is necessary to fix this."
  
  Revision  Changes    Path
  1.4       +7 -2      xml-soap/java/src/org/apache/soap/server/http/ServerHTTPUtils.java
  
  Index: ServerHTTPUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/http/ServerHTTPUtils.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ServerHTTPUtils.java	2000/10/17 12:03:41	1.3
  +++ ServerHTTPUtils.java	2000/10/23 19:09:43	1.4
  @@ -130,8 +130,13 @@
       Reader requestReader = req.getReader ();
       char[] payload = new char[contentLength];
       int    offset = 0;
  -    while (offset < contentLength) {
  -      offset += requestReader.read (payload, offset, contentLength - offset);
  +    int    bytesRead = 0;
  +    
  +    // We're done reading when we get all the content OR when the stream
  +    // returns a -1.
  +    while ((offset < contentLength) && (bytesRead >= 0)) {
  +      bytesRead = requestReader.read (payload, offset, contentLength - offset);
  +      offset += bytesRead;
       }
   
       // Parse the stuff