ppkarwasz commented on code in PR #735:
URL: https://github.com/apache/commons-compress/pull/735#discussion_r2443293794
##########
src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java:
##########
@@ -1777,27 +1764,17 @@ private void readPackInfo(final ByteBuffer header,
final Archive archive) throws
}
}
- private StartHeader readStartHeader(final long startHeaderCrc) throws
IOException {
- // using Stream rather than ByteBuffer for the benefit of the built-in
CRC check
- try (DataInputStream dataInputStream = new
DataInputStream(ChecksumInputStream.builder()
- // @formatter:off
- .setChecksum(new CRC32())
- .setInputStream(new
BoundedSeekableByteChannelInputStream(channel, 20))
- .setCountThreshold(20L)
- .setExpectedChecksumValue(startHeaderCrc)
- .get())) {
- // @formatter:on
- final long nextHeaderOffset = readRealUint64(dataInputStream);
- if (nextHeaderOffset > channel.size() - SIGNATURE_HEADER_SIZE) {
- throw new ArchiveException("nextHeaderOffset is out of
bounds");
- }
- final int nextHeaderSize = toNonNegativeInt("nextHeaderSize",
readRealUint64(dataInputStream));
- if (nextHeaderSize > channel.size() - SIGNATURE_HEADER_SIZE -
nextHeaderOffset) {
- throw new ArchiveException("nextHeaderSize is out of bounds");
- }
- final long nextHeaderCrc = readUint32(dataInputStream);
- return new StartHeader(nextHeaderOffset, nextHeaderSize,
nextHeaderCrc);
+ private StartHeader readStartHeader(final ByteBuffer startHeader) throws
IOException {
+ final long nextHeaderOffset = readRealUint64(startHeader);
+ if (nextHeaderOffset > channel.size() - SIGNATURE_HEADER_SIZE) {
+ throw new ArchiveException("nextHeaderOffset is out of bounds");
+ }
+ final int nextHeaderSize = toNonNegativeInt("header",
readRealUint64(startHeader));
+ if (nextHeaderSize > channel.size() - SIGNATURE_HEADER_SIZE -
nextHeaderOffset) {
+ throw new ArchiveException("nextHeaderSize is out of bounds");
Review Comment:
Fixed in
https://github.com/apache/commons-compress/pull/735/commits/e521e451ce2bf7606ee9ce7b3b595008a76dcc4f
--
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]