yakovsh commented on code in PR #435:
URL: https://github.com/apache/commons-compress/pull/435#discussion_r1388574923
##########
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:
This method only has "throws IOException", so someone calling it within a
try/catch block wouldn't be expecting other exceptions to appear. I considered
changing the one in initializeTables() to IOException but it is called by other
classes and I didn't want the change to be disruptive.
--
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]