Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 52c8e70

Browse files
Little improvement on the division to calculate the compression ratio
1 parent fe41a9c commit 52c8e70

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/main/java/com/venafi/vcert/sdk/connectors/cloud/CloudConnectorUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ public static PEMCollection getPEMCollectionFromKeyStoreAsStream(InputStream key
459459

460460
private static String readZipEntry(ZipEntry zipEntry, ZipInputStream zis, String certId) throws VCertException, IOException {
461461

462-
int totalSizeEntry = 0;
462+
long totalSizeEntry = 0;
463463

464464
final int MAX_RATIO = 3;//It's expected that the compression ratio should't be more than 3
465465

@@ -473,7 +473,7 @@ private static String readZipEntry(ZipEntry zipEntry, ZipInputStream zis, String
473473
//If the compression ratio of the current unzipped file is major that the expected
474474
// max ratio
475475
totalSizeEntry += nBytes;
476-
double compressionRatio = totalSizeEntry / zipEntry.getCompressedSize();
476+
long compressionRatio = totalSizeEntry / zipEntry.getCompressedSize();
477477
if(compressionRatio > MAX_RATIO) {
478478
// ratio between compressed and uncompressed data is highly suspicious, looks like a Zip Bomb Attack
479479
throw new KeyStoreZipCompressionRatioExceeded(certId, zipEntry.getName(), MAX_RATIO);

0 commit comments

Comments
 (0)