tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lucian Cionca <lcio...@savvion.com>
Subject Re: ERROR using multipart/form-data POST request
Date Fri, 27 Apr 2001 18:17:32 GMT
The reason for this is a bug in the doRead() method of Ajp13ConnectorRequest, which
causes the
doRead(byte[] b, int off, int len) in that same class to prematurely end processing
.
The bug is in the conversion of the value read from the bodyBuff byte-array, to an
integer result. Bytes can have values
from -128 to 127, while the result is expected to be a positive integer (in the
range 0 to 255). A result of -1 is interpreted in the
doRead(byte[] b, int off, int len) method as an error/end of input.

The patch to Tomcat sources is very simple. In function "int doRead()"
in Ajp13ConnectorRequest.java instead of the line

        return bodyBuff[pos++];

the line
        return bodyBuff[pos++] & 0xFF;

should be used.

Credit for the solution should go to Amir Nuri <amir.nuri@mobilitec.com> who
indicated the solution to me.

 On the other hand there is always the workaround to use ajp12 for the specific
servlets that use multipart/form-data POST.

Regards,
Lucian

Andrey Kartashov wrote:

> On Fri, Apr 27, 2001 at 03:57:43AM +0200, Incze Lajos wrote:
> > > This error hapens when I try to upload file using form with
> > > enctype="multipart/form-data" and method="post".
> > >
> > > The environment: Linux(2.4.3), Apache(1.3.19),
> > > mod_jk and Tomcat (3.2.1), using ajp13 protocol.
> > >
> > >
> > > I can't seem to find anything like that in apache bug tracking system.
> > > Did anyone have any experience using multipart/form-data with similar
> > > server configuration?
> > >
> > I think you should change to an 3.2.2 beta, as modjk had some difficulties
> > in the 3.2.1 tomcat release.                                       incze
>
> I just tested ajp12 protocol and it doesn't have this bug.
> I'm going to test 3.2.2 stuff as well some time later:) Just in case if someone
> else wants to try - this bug is triggered when uploading binary data
> (like image file). Uploading of the text file works (even a big one).
> I'd guess that code uses string functions somewhere where binary read/write
> would be more appropriate.
>
> --
> oo Andrey
> oo
> oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo
> "All mail clients suck. This one just sucks less."
>            -- http://www.mutt.org/  Jeremy Blosser
> oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo


Mime
View raw message