anshuksi282-ksolves commented on code in PR #8622:
URL: https://github.com/apache/hadoop/pull/8622#discussion_r3629706509
##########
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:
Thanks for the review @pjfanning!
Updated to use `Math.multiplyExact` for both `buf` and `checksum` buffer
size checks, as suggested.
I did try adding a dedicated test for the `checksum` buffer overflow path,
but `getChecksumSize()` returns a fixed value from `DataChecksum.Type` (e.g. 4
for CRC32), so it can never actually be large enough to overflow — that path
isn't reachable in practice, just defensive. So I've kept the existing unit
test covering the `buf` overflow case, and re-ran `TestFSOutputSummer`,
`TestChecksumFileSystem`, and `TestChecksumFs` to confirm no regressions.
--
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]