Summary: | InternalAprInputBuffer.fill() doesn't deal correctly with EOF | ||
---|---|---|---|
Product: | Tomcat Native | Reporter: | Hugh Warrington <hugh> |
Component: | Library | Assignee: | Tomcat Developers Mailing List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | hugh |
Priority: | P2 | ||
Version: | 1.1.20 | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Linux | ||
Attachments: |
2011-08-26_tc55_50394_InternalAprInputBuffer.patch
2011-08-26_tc6_50394_InternalAprInputBuffer.patch |
Description
Hugh Warrington
2010-12-01 11:38:03 UTC
The code in org/apache/coyote/http11/InternalAprInputBuffer is: +++ nRead = Socket.recvbb(socket, 0, buf.length - lastValid); if (nRead > 0) { bbuf.limit(nRead); bbuf.get(buf, pos, nRead); lastValid = pos + nRead; } else { if ((-nRead) == Status.ETIMEDOUT || (-nRead) == Status.TIMEUP) { throw new SocketTimeoutException(sm.getString("iib.failedread")); } else { throw new IOException(sm.getString("iib.failedread")); } } +++ So returning 0 won't help. Ok, well perhaps my proposed fix won't work, but this is still an issue since it's not conforming to the InputStream specification. Fix by 1148254 backport proposed. We hit this issue yesterday with tomcat-native-1.1.20 when uploading 1G file. But found that if we did not use BufferedInputStream and read directly into a buffer it worked fine. InputStream in = request.getInputStream(); //new BufferedInputStream(request.getInputStream()); int bytesRead; while ((bytesRead = in.read(buf)) != -1) { out.write(buf, 0, bytesRead); } (In reply to comment #3) > Fix by 1148254 backport proposed. There is some confusion on the status of this issue. The r1148254 mentioned above was essentially reverted by r1148815. The actual fix is in Tomcat-Native 1.1.22 by r1148814. Native 1.1.22 is already released - you may download it. It seems that part of r1148815 still needs a backport to 6.0 and 5.5: s/} else {/} else if (nRead != 0) {/ Created attachment 27437 [details]
2011-08-26_tc55_50394_InternalAprInputBuffer.patch
Created attachment 27438 [details]
2011-08-26_tc6_50394_InternalAprInputBuffer.patch
Proposed the patches for Tomcat 6.0 and 5.5. Fixed in 6.0.x and will be included in 6.0.34 onwards Fixed in 5.5.x with r1171684 and will be in 5.5.34 onwards. |