yakovsh commented on code in PR #435:
URL: https://github.com/apache/commons-compress/pull/435#discussion_r1388589483
##########
src/main/java/org/apache/commons/compress/compressors/z/ZCompressorInputStream.java:
##########
@@ -72,6 +72,12 @@ public ZCompressorInputStream(final InputStream inputStream,
final int memoryLim
if (blockMode) {
setClearCode(DEFAULT_CODE_SIZE);
}
+ // maxCodeSize cannot be zero, otherwise initializeTables() will throw
an IllegalArgumentException
+ // maxCodeSize shifted cannot be less than 256, otherwise the loop in
initializeTables() will throw an ArrayIndexOutOfBoundsException
+ // maxCodeSize cannot be smaller than getCodeSize(), otherwise
addEntry() will throw an ArrayIndexOutOfBoundsException
+ if (maxCodeSize <= 0 || (1 << maxCodeSize) < 256 || getCodeSize() >
maxCodeSize) {
+ throw new IOException("Invalid maxCodeSize value: " + maxCodeSize);
Review Comment:
I dug back into the code and it looks like the zero check is redundant
anyway because getCodeSize() will be set to 9 by default so anything negative
would error out regardless
--
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]