Skip to content

Commit 85682f8

Browse files
committed
Merge branch '3.3.x'
Closes gh-42080
2 parents 9b85c73 + 101ed0e commit 85682f8

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/zip/FileDataBlock.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,15 @@ public int read(ByteBuffer dst, long pos) throws IOException {
7171
throw new IllegalArgumentException("Position must not be negative");
7272
}
7373
ensureOpen(ClosedChannelException::new);
74-
int remaining = (int) (this.size - pos);
74+
long remaining = this.size - pos;
7575
if (remaining <= 0) {
7676
return -1;
7777
}
7878
int originalDestinationLimit = -1;
7979
if (dst.remaining() > remaining) {
8080
originalDestinationLimit = dst.limit();
81-
dst.limit(dst.position() + remaining);
81+
long updatedLimit = dst.position() + remaining;
82+
dst.limit((updatedLimit > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) updatedLimit);
8283
}
8384
int result = this.fileAccess.read(dst, this.offset + pos);
8485
if (originalDestinationLimit != -1) {

spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/zip/ZipContent.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,8 @@ private static ZipContent loadContent(Source source, Kind kind, FileDataBlock da
636636
private static long getStartOfZipContent(FileDataBlock data, ZipEndOfCentralDirectoryRecord eocd,
637637
Zip64EndOfCentralDirectoryRecord zip64Eocd) throws IOException {
638638
long specifiedOffsetToStartOfCentralDirectory = (zip64Eocd != null)
639-
? zip64Eocd.offsetToStartOfCentralDirectory() : eocd.offsetToStartOfCentralDirectory();
639+
? zip64Eocd.offsetToStartOfCentralDirectory()
640+
: Integer.toUnsignedLong(eocd.offsetToStartOfCentralDirectory());
640641
long sizeOfCentralDirectoryAndEndRecords = getSizeOfCentralDirectoryAndEndRecords(eocd, zip64Eocd);
641642
long actualOffsetToStartOfCentralDirectory = data.size() - sizeOfCentralDirectoryAndEndRecords;
642643
return actualOffsetToStartOfCentralDirectory - specifiedOffsetToStartOfCentralDirectory;
@@ -650,7 +651,8 @@ private static long getSizeOfCentralDirectoryAndEndRecords(ZipEndOfCentralDirect
650651
result += Zip64EndOfCentralDirectoryLocator.SIZE;
651652
result += zip64Eocd.size();
652653
}
653-
result += (zip64Eocd != null) ? zip64Eocd.sizeOfCentralDirectory() : eocd.sizeOfCentralDirectory();
654+
result += (zip64Eocd != null) ? zip64Eocd.sizeOfCentralDirectory()
655+
: Integer.toUnsignedLong(eocd.sizeOfCentralDirectory());
654656
return result;
655657
}
656658

@@ -796,18 +798,18 @@ public CloseableDataBlock openContent() throws IOException {
796798
private FileDataBlock getContent() throws IOException {
797799
FileDataBlock content = this.content;
798800
if (content == null) {
799-
int pos = this.centralRecord.offsetToLocalHeader();
801+
long pos = Integer.toUnsignedLong(this.centralRecord.offsetToLocalHeader());
800802
checkNotZip64Extended(pos);
801803
ZipLocalFileHeaderRecord localHeader = ZipLocalFileHeaderRecord.load(ZipContent.this.data, pos);
802-
int size = this.centralRecord.compressedSize();
804+
long size = Integer.toUnsignedLong(this.centralRecord.compressedSize());
803805
checkNotZip64Extended(size);
804806
content = ZipContent.this.data.slice(pos + localHeader.size(), size);
805807
this.content = content;
806808
}
807809
return content;
808810
}
809811

810-
private void checkNotZip64Extended(int value) throws IOException {
812+
private void checkNotZip64Extended(long value) throws IOException {
811813
if (value == 0xFFFFFFFF) {
812814
throw new IOException("Zip64 extended information extra fields are not supported");
813815
}

0 commit comments

Comments
 (0)