-
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stax maxAttributeSize
limit is only vaguely respected
#93
Comments
This is by design tho. Amount of overhead for checking for each and every character makes it less than desirable to do that -- I don't want parsing to be measurable slower. So, while I'll consider this I will most likely consider this "working as expected" -- limit check is not meant to be precise. |
There are many comparisons done for each character and this is just one extra simple |
There should not be any need to check for the limit for every character. The bug is that the limit is checked against com.ctc.wstx.util.TextBuilder#mBufferLen which is not updated because com.ctc.wstx.util.TextBuilder#append is bypassed. mBufferLen is only updated by bufferFull which sets it to the buffers length before the buffer is expanded. The limit will not be checked against the next buffer size, nor the current buffer size but to what the buffer size was prior to the last expansion. In one trace I did on 4.2.0, the following checks were made:
|
maxAttributeSize
limit is only vaguely respected
@istudens Thank you for reporting this and contributing the patch! I ended up implementing it slightly differently, party to remove once per loop check, but also because testing reminded me of one implementation peculiarity: Fix will go in 6.0.3, whenever I release that. |
Hello,
System property org.apache.cxf.stax.maxAttributeSize only vaguely limits attribute values. If it is set to 5000 it can send up to 8295 characters in an attribute value without denying the request.
The culprit is that the limit is checked against the size of the buffer before the last buffer expansion. After 2459 characters the buffer is grown to 3687. After 5531 characters the limit is checked against 3687 instead of 5531 and not until 8296 characters is the limit checked against the previous buffer size 5531 which is larger than 5000.
I am going to file a PR with fix + testcase immediately.
The text was updated successfully, but these errors were encountered: