www-apache-bugdb mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Smirl <jonsm...@mediaone.net>
Subject mod_jserv/5500: over 1K post data is not being handled correctly
Date Tue, 21 Dec 1999 02:24:23 GMT

>Number:         5500
>Category:       mod_jserv
>Synopsis:       over 1K post data is not being handled correctly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    jserv
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Mon Dec 20 18:30:06 PST 1999
>Last-Modified:
>Originator:     jonsmirl@mediaone.net
>Organization:
apache
>Release:        1.3.9 1.1b3
>Environment:
Win95, MS JVM
>Description:
I think I've figured out the root of the problem.  A fix I submitted about
two months ago is not exactly right. It is revision 1.68
JServeConnection.java. In the original fix I had not allowed for a partial
read fill from the socket. A partial read fill may occur on some OS's if
there is over 1K of post data.
>How-To-Repeat:
post over 1K of data to JServ on Windows
>Fix:
    /**
     * ServletInputStream implementation as inner class
     */
    protected class JServInputStream extends ServletInputStream {

        protected InputStream in;
 protected int length;

        public JServInputStream(int length, InputStream in) {
     this.length = length;
            this.in = in;
        }

        public int read() throws IOException

   if ((length > 0) || (length == -1)) {
     int i = in.read();
     length -= i;
     return i;
   }
   return -1;
        }

        public int read(byte b[]) throws IOException {
     if (length == -1)
       return in.read(b, 0, b.length);

     int len = b.length;
     if (len > length)
       len = length;
     if (len > 0) {
       int i = in.read(b, 0, len);
       length -= i;
       return i;
     }
     return 0;
        }

        public int read(byte b[], int off, int len) throws IOException {
     if (length == -1)
              return in.read(b, off, len);

     if (len > length)
       len = length;
     if (len > 0) {
       int i = in.read(b,off,len);
       length -= i;
       return i;
     }
     return 0;
        }

        public long skip(long n) throws IOException {
     if (length == -1)
              return in.skip(n);

     if (n > length)
       n = length;
     length -= n;
     if (n > 0) {
       long i = in.skip(n);
              length -= i;
       return i;
     }
     return 0;
        }

        public void close() throws IOException {
            // Ignore closing of the input stream since it also
            // close the output stream.
            // conn.in.close();
        }

        /**
            We must implement this method because java.io.InputStream
            javadocs says that this will return 0. Since we use a long
            internally, it must be cast to an int. ugly. -JSS
        */
        public int available() throws IOException {
     if (length == -1)
       return in.available();
            return length;
        }

    }



>Audit-Trail:
>Unformatted:
[In order for any reply to be added to the PR database, you need]
[to include <apbugs@Apache.Org> in the Cc line and make sure the]
[subject line starts with the report component and number, with ]
[or without any 'Re:' prefixes (such as "general/1098:" or      ]
["Re: general/1098:").  If the subject doesn't match this       ]
[pattern, your message will be misfiled and ignored.  The       ]
["apbugs" address is not added to the Cc line of messages from  ]
[the database automatically because of the potential for mail   ]
[loops.  If you do not include this Cc, your reply may be ig-   ]
[nored unless you are responding to an explicit request from a  ]
[developer.  Reply only with text; DO NOT SEND ATTACHMENTS!     ]




Mime
View raw message