HDFS-11719. Arrays.fill() wrong index in BlockSender.readChecksum() exception handling. Contributed by Tao Zhang

This commit is contained in:
Mingliang Liu 2018-09-18 10:20:15 -07:00
parent 48319d6eee
commit 6ff509c32a
1 changed files with 4 additions and 3 deletions

View File

@ -682,16 +682,17 @@ private void readChecksum(byte[] buf, final int checksumOffset,
+ " at offset " + offset + " for block " + block, e);
ris.closeChecksumStream();
if (corruptChecksumOk) {
if (checksumOffset < checksumLen) {
if (checksumLen > 0) {
// Just fill the array with zeros.
Arrays.fill(buf, checksumOffset, checksumLen, (byte) 0);
Arrays.fill(buf, checksumOffset, checksumOffset + checksumLen,
(byte) 0);
}
} else {
throw e;
}
}
}
/**
* Compute checksum for chunks and verify the checksum that is read from
* the metadata file is correct.