Hi,
this is not a bug. In your code, change the line:
             actualRead = in.read(bytes, bytesRead, contentLength);
to:
             actualRead = in.read(bytes, bytesRead, contentLength -
bytesRead);

Orion is throwing an IOB exception back at you per the InputStream
specification since the specified offset + length doesnt fit into the byte[]
supplied (from the API: "If off is negative, or len is negative, or off+len
is greater than the length of the array b, then an IndexOutOfBoundsException
is thrown."). We have extended the error message now so it will in your case
read (for a large file):
java.lang.IndexOutOfBoundsException: The supplied offset + length did not
fit into the supplied byte[] (offset + length = 2048 + 12590395 = 12592443
vs byte[].length = 12590395)

As for bug reporting Orion-Interest not meant for that, I'd recommend you to
use bugzilla (www.orionserver.com -> bugzilla), that way others interested
in the bug can follow it/augment it too.

Hope it helps, have a nice day!

/Magnus Stenman, the Orion team

PS. Great that you supplied the source! That is always encouraged and will
make our job easer in hunting stuff down. Without source this would probably
have costed us a lot more timewise by bulletproofing (again) the read(...)
method. Reports that send a simple testcase (like this one) in the form of a
.war, .ear or .java naturally receive a higher priority than those without.



----- Original Message -----
From: "Scott Lawrence" <[EMAIL PROTECTED]>
To: "Orion-Interest" <[EMAIL PROTECTED]>
Sent: Tuesday, September 05, 2000 7:34 AM
Subject: 1.2.9 bug: InputStream from request throwing an exception


> Orion 1.2.9
> Windows 2000
> J2SE 1.3.0
>
> Bug: Underlying InputStream from request.getInputStream() throws an
> exception when the input stream should return more than 2048 bytes.
>
> Example: The following error occurs when running the JSP and servlet
below.
> The underlying input stream seems to throw and exception during
in.read(...)
> when trying to upload a file that's greater than 2048 (actually when the
> file + the extra multi encoding  > 2048).  I've tried this on Tomcat 3.2b
> and it works fine.  I've used similar code on older servers (not orion)
and
> didn't have this problem.  I'm writing this to the users group as well in
> case others are having problems with this.  If you work with file
uploading
> through forms, this will certainly hamper your progress.
>
>
> 500 Internal Server Error
> java.lang.IndexOutOfBoundsException
> at com.evermind.server.http.ep.read(JAX)
> at InputStreamBug.doPost(InputStreamBug.java:21)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java)
> at com.evermind.server.http.du.rr(JAX)
> at com.evermind.server.http.du.forward(JAX)
> at com.evermind.server.http.d5.rx(JAX)
> at com.evermind.server.http.d5.rw(JAX)
> at com.evermind.util.f.run(JAX)
>
> InputStreamBug.jsp--------------------------------
> <%@page contentType="text/html"%>
> <html>
> <head><title>InputStreamBug</title></head>
> <body>
> <FORM action='servlet/InputStreamBug' enctype='multipart/form-data'
> method='post'>
>     <INPUT type='file' name='filename'><BR>
>     <INPUT type='submit' name='submit' value='Upload'>
> </FORM>
> </body>
> </html>
>
>
> InputStreamBug.java-------------------------------
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> import java.util.*;
>
> public class InputStreamBug extends HttpServlet {
>     /**
>      * Reads the input stream and outputs the results to the output
stream.
>      */
>     public void doPost(HttpServletRequest request, HttpServletResponse
> response)
>             throws IOException{
>         response.setContentType("text/html");
>         InputStream in     = request.getInputStream();
>         OutputStream out   = response.getOutputStream();
>         int contentLength  = request.getContentLength();
>         byte[] bytes       = new byte[contentLength];
>         int actualRead     = 0;
>         int bytesRead      = 0;
>
>         while (bytesRead < contentLength) {
>             actualRead = in.read(bytes, bytesRead, contentLength);
>             bytesRead += actualRead;
>         }
>         out.write(bytes);
>     }
> }
>



Reply via email to