You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2018/01/12 13:04:33 UTC
[Bug 61993] New: org.apache.tomcat.util.ByteChunk throws
NegativeArray SizeException
https://bz.apache.org/bugzilla/show_bug.cgi?id=61993
Bug ID: 61993
Summary: org.apache.tomcat.util.ByteChunk throws NegativeArray
SizeException
Product: Tomcat 7
Version: 7.0.82
Hardware: PC
OS: Linux
Status: NEW
Keywords: Beginner, PatchAvailable, PortForward
Severity: minor
Priority: P2
Component: Catalina
Assignee: dev@tomcat.apache.org
Reporter: davecrighton@uk.ibm.com
Target Milestone: ---
Created attachment 35675
--> https://bz.apache.org/bugzilla/attachment.cgi?id=35675&action=edit
If growing the buffer would overflow int then just set to max value
We use ByteChunk to read in the request body and we noticed 2 things.
1.) The length of ByteChunk is limited to MAX_INT so for our purposes we can
only process 2Gb requests before we need to alter our reading code.
2.) The way that ByteChunk grows means that in practice you can often only use
up to 1Gb of space.
The followign exception stack is thrown when append is called on and ByteChunk
over 1Gb in size:
java.lang.NegativeArraySizeException:java.lang.NegativeArraySizeException at
org.apache.tomcat.util.buf.ByteChunk.makeSpace(ByteChunk.java:527) at
org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:327)
Looking at issue number 1 it looks like a lot of classes would need to be
changed to use long but I do have a patch for a trivial check that allowed us
to process 2Gb requests.
Obviously this could silently truncate once you actually reach INT_MAX but it
seems from the previous check based on the limit that this is the desired
behaviour rather than to throw an exception.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 61993] org.apache.tomcat.util.ByteChunk throws NegativeArray
SizeException
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61993
Mark Thomas <ma...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from Mark Thomas <ma...@apache.org> ---
Fixed in:
- trunk for 9.0.4 onwards
- 8.5.x for 8.5.27 onwards
- 8.0.x for 8.0.49 onwards
- 7.0.x for 7.0.84 onwards
Thanks for the patch - it is appreciated. It is just that with all the
refactoring to reduce duplication and fix the various other edge cases I ended
up taking a slightly different approach.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 61993] org.apache.tomcat.util.ByteChunk throws NegativeArray
SizeException
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61993
--- Comment #3 from Mark Thomas <ma...@apache.org> ---
Typically, we add tests like that with the @Ignore annotation so we can run
them easily from the IDE but they aren't run by the CI systems.
I've looked at this further over the weekend and there are subtle differences
between ByteChunk and CharChunk that don't look right - as well as quite a lot
of duplication.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 61993] org.apache.tomcat.util.ByteChunk throws NegativeArray
SizeException
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61993
Dave Crighton <da...@uk.ibm.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |davecrighton@uk.ibm.com
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 61993] org.apache.tomcat.util.ByteChunk throws NegativeArray
SizeException
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61993
--- Comment #2 from Dave Crighton <da...@uk.ibm.com> ---
Thanks Mark,
I did consider submitting my own JUnit with the patch but it causes large
allocations which, at least for our own build systems, makes it unsuitable at
an operational level for automated unit test (requires higher heap sizes, slows
down the build etc).
Wasn't sure what the best practice for the project is.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 61993] org.apache.tomcat.util.ByteChunk throws NegativeArray
SizeException
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61993
--- Comment #5 from Dave Crighton <da...@uk.ibm.com> ---
Thanks Mark. We'll pick up the fix for our main product builds in 7.0.84.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 61993] org.apache.tomcat.util.ByteChunk throws NegativeArray
SizeException
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61993
--- Comment #6 from adv ydv <ad...@gmail.com> ---
One of the most popular http://solitairetimes.com game in the world great for a
person just to relax and claiming.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 61993] org.apache.tomcat.util.ByteChunk throws NegativeArray
SizeException
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61993
--- Comment #1 from Mark Thomas <ma...@apache.org> ---
Thanks for the report.
On closer inspection there appear to be a couple of other edge cases that could
be handled better.
I plan on putting together some unit tests to cover this case and the other
edge cases.
Note that CharChunk is likely to have similar issues.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org