coheigea commented on PR #3463:
URL: https://github.com/apache/cxf/pull/3463#issuecomment-5665471746
@reta Some comments from Claude:
### 1. `maxElementCount` default overflows (blocking)
```java
getLong(MAX_ELEMENT_COUNT, Math.max(100 * MAX_CHILD_ELEMENTS_VAL, 50000));
```
`MAX_CHILD_ELEMENTS_VAL` is an `int`, so `100 * ...` is int arithmetic — the
widening to `long` only happens after `Math.max(int,int)` has returned. It
overflows once `maxChildElements > 21_474_836`:
| `maxChildElements` | resulting `MAX_ELEMENT_COUNT_VAL` |
|---|---|
| 50 000 (default) | 5 000 000 |
| 30 000 000 | 50 000 |
| `Integer.MAX_VALUE` | 50 000 (`100 * Integer.MAX_VALUE` wraps to `-100`,
so the floor wins) |
That inverts the invariant the comment states — the total element count ends
up well *below* the per-parent child count. It also hits precisely the users
most likely to notice: `getInteger`/`getLong` coerce negatives back to the
default, so there is no `-1` escape hatch and raising `maxChildElements` is the
only way to relax that limit today. Anyone doing so would silently pick up a 50
000 total-element cap on upgrade.
One character:
```java
getLong(MAX_ELEMENT_COUNT, Math.max(100L * MAX_CHILD_ELEMENTS_VAL, 50000L));
```
### 2. Derive `maxXMLCharacters` from `MAX_TEXT_LENGTH_VAL`
Your rationale above is "2x of MAX_TEXT_LENGTH" and the new code comment
says the two "should be aligned", but the code hardcodes 256Mb — so the
alignment breaks as soon as anyone sets `org.apache.cxf.stax.maxTextLength`.
Raise it to 512Mb and the document-wide character cap is *smaller* than a
single permitted text segment: a contradictory config that worked fine before
this change.
```java
private static final long MAX_XML_CHARS_VAL =
getLong(MAX_XML_CHARACTERS, 2L * MAX_TEXT_LENGTH_VAL); // 256Mb by
default
```
Same default (2 x 128Mb), stays correct under reconfiguration, and makes the
comment true rather than aspirational. If you'd rather keep the literal, at
least `256L * 1024 * 1024` so a future bump doesn't overflow.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]