pjfanning commented on code in PR #8622:
URL: https://github.com/apache/hadoop/pull/8622#discussion_r3629479896
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FSOutputSummer.java:
##########
@@ -52,6 +53,9 @@ abstract public class FSOutputSummer extends OutputStream
implements
protected FSOutputSummer(DataChecksum sum) {
this.sum = sum;
+ Preconditions.checkArgument(
+ sum.getBytesPerChecksum() * BUFFER_NUM_CHUNKS > 0,
Review Comment:
I would do something like:
```
int bufArraySize;
try {
bufArraySize = math.multiplyExact(sum.getBytesPerChecksum(),
BUFFER_NUM_CHUNKS);
} catch (ArithmeticException ae) {
throw new IllegalArgumentException("The calculated buffer array size for
FSOutputSummer is too large");
}
this.buf = new byte[bufArraySize];
```
I would suggest that you also check the array size in a similar way for
`this.checksum`.
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FSOutputSummer.java:
##########
@@ -52,6 +53,9 @@ abstract public class FSOutputSummer extends OutputStream
implements
protected FSOutputSummer(DataChecksum sum) {
this.sum = sum;
+ Preconditions.checkArgument(
+ sum.getBytesPerChecksum() * BUFFER_NUM_CHUNKS > 0,
Review Comment:
I would do something like:
```
int bufArraySize;
try {
bufArraySize = Math.multiplyExact(sum.getBytesPerChecksum(),
BUFFER_NUM_CHUNKS);
} catch (ArithmeticException ae) {
throw new IllegalArgumentException("The calculated buffer array size for
FSOutputSummer is too large");
}
this.buf = new byte[bufArraySize];
```
I would suggest that you also check the array size in a similar way for
`this.checksum`.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]