yihua commented on code in PR #20321:
URL: https://github.com/apache/hudi/pull/20321#discussion_r4286963147


##########
hudi-io/src/main/java/org/apache/hudi/io/hfile/HFileBlock.java:
##########
@@ -147,18 +146,24 @@ protected HFileBlock(HFileContext context,
    * Rejects impossible header sizes before they are used to allocate buffers 
or locate content.
    */
   private void validateHeader(byte[] byteBuff, int startOffsetInBuff) {
-    long blockEndInBuff = (long) startOffsetInBuff + HFILEBLOCK_HEADER_SIZE + 
onDiskSizeWithoutHeader;
-    long unpackedSize = (long) HFILEBLOCK_HEADER_SIZE + 
uncompressedSizeWithoutHeader + sizeCheckSum;
+    long onDiskSizeWithHeader = (long) HFILEBLOCK_HEADER_SIZE + 
onDiskSizeWithoutHeader;
+    long blockEndInBuff = startOffsetInBuff + onDiskSizeWithHeader;
+    // Long math, unlike numChecksumBytes, so a corrupt bytesPerChecksum 
cannot throw here
+    long checksumBytes = bytesPerChecksum > 0
+        ? (onDiskSizeWithHeader + bytesPerChecksum - 1) / bytesPerChecksum * 
CHECKSUM_SIZE : 0;

Review Comment:
   Modify `numChecksumBytes(getOnDiskSizeWithHeader(), bytesPerChecksum)` to 
use long calculation, so this is not duplicated.



-- 
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]

Reply via email to