rzo1 commented on code in PR #1022:
URL: https://github.com/apache/opennlp/pull/1022#discussion_r3145145260
##########
opennlp-core/opennlp-ml/opennlp-ml-commons/src/main/java/opennlp/tools/ml/model/ModelParameterChunker.java:
##########
@@ -87,6 +89,10 @@ public static String readUTF(DataInputStream dis) throws
IOException {
if (data.startsWith(SIGNATURE_CHUNKED_PARAMS)) {
String chunkElements = data.replace(SIGNATURE_CHUNKED_PARAMS, "");
int chunkSize = Integer.parseInt(chunkElements);
+ if (chunkSize <= 0 || chunkSize > AbstractModelReader.MAX_ENTRIES) {
Review Comment:
Looking at it with a fresh brain and some ☕ , you are both right. I think,
it might be good **follow-up** to
1. Wrap parseInt in try/catch and rethrow as IOException (or
IllegalArgumentException) with a clear message like "Malformed chunked-params
header: <value>".
2. Sanity check chunkSize >= 0 (and probably > 0 with a log msg), reject
otherwise.
3. Document @throws on the method.
--
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]