You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@opennlp.apache.org by "rzo1 (via GitHub)" <gi...@apache.org> on 2026/06/12 14:12:41 UTC
[PR] OPENNLP-1821: Prevent OutOfMemory due to huge array allocation (1.x) (opennlp)
rzo1 opened a new pull request, #1079:
URL: https://github.com/apache/opennlp/pull/1079
Backport of #1022 to `opennlp-1.x`.
## Problem
`AbstractModelReader` read count fields (outcomes, outcome patterns, predicates) directly from the model stream and used them as array sizes. A crafted model could declare an oversized or negative count and trigger an `OutOfMemoryError` / DoS before any payload was read.
## Fix
- Each count is validated against a configurable upper bound `MAX_ENTRIES` (default `10_000_000`, overridable via the `OPENNLP_MAX_ENTRIES` system property).
- Negative counts are rejected with `IllegalArgumentException` before allocation.
## 1.x adaptations vs. the 2.x change
- Test ported from JUnit 5 to JUnit 4 (`AbstractModelReaderOomTest`).
- The 2.x `ModelParameterChunker` hunk is omitted: that class does not exist on `opennlp-1.x`, and the change there was a cosmetic blank line only.
Tests: `AbstractModelReaderOomTest` (8) pass on Temurin JDK 8.
--
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: dev-unsubscribe@opennlp.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [1.x] OPENNLP-1821: Prevent OutOfMemory due to huge array allocation (opennlp)
Posted by "mawiesne (via GitHub)" <gi...@apache.org>.
mawiesne merged PR #1079:
URL: https://github.com/apache/opennlp/pull/1079
--
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: dev-unsubscribe@opennlp.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org