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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
