You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/12/27 22:32:36 UTC

[commons-compress] branch master updated (98f634be -> 382d3026)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git


    from 98f634be Fix PMD TooManyStaticImports
     new 16cf484a Use Arrays.copyOfRange()
     new 382d3026 Format tweaks

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../compress/archivers/zip/PKWareExtraHeader.java       |  1 +
 .../archivers/zip/X0015_CertificateIdForFile.java       |  1 +
 .../archivers/zip/X0017_StrongEncryptionHeader.java     | 17 +++++++----------
 3 files changed, 9 insertions(+), 10 deletions(-)


[commons-compress] 01/02: Use Arrays.copyOfRange()

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 16cf484a8284b95b30b66a42f30de24a55497093
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Dec 27 17:31:32 2022 -0500

    Use Arrays.copyOfRange()
---
 .../archivers/zip/X0017_StrongEncryptionHeader.java      | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/X0017_StrongEncryptionHeader.java b/src/main/java/org/apache/commons/compress/archivers/zip/X0017_StrongEncryptionHeader.java
index e0ee21cb..3c75a40f 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/X0017_StrongEncryptionHeader.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/X0017_StrongEncryptionHeader.java
@@ -384,13 +384,11 @@ public class X0017_StrongEncryptionHeader extends PKWareExtraHeader {
                 throw new ZipException("Invalid X0017_StrongEncryptionHeader: resize " + resize
                     + " is too small to hold hashSize" + this.hashSize);
             }
-            this.recipientKeyHash = new byte[this.hashSize];
-            this.keyBlob = new byte[resize - this.hashSize];
             // TODO: this looks suspicious, 26 rather than 24 would be "after" resize
             assertDynamicLengthFits("resize", resize, ivSize + 24 + erdSize, length);
-            // TODO use Arrays.copyOfRange
-            System.arraycopy(data, offset + ivSize + 24 + erdSize, this.recipientKeyHash, 0, this.hashSize);
-            System.arraycopy(data, offset + ivSize + 24 + erdSize + this.hashSize, this.keyBlob, 0, resize - this.hashSize);
+            //
+            this.recipientKeyHash = Arrays.copyOfRange(data, offset + ivSize + 24 + erdSize, this.hashSize);
+            this.keyBlob = Arrays.copyOfRange(data, offset + ivSize + 24 + erdSize + this.hashSize, resize - this.hashSize);
 
             assertMinimalLength(ivSize + 26 + erdSize + resize + 2, length);
             final int vSize = ZipShort.getValue(data, offset + ivSize + 26 + erdSize + resize);
@@ -400,11 +398,9 @@ public class X0017_StrongEncryptionHeader extends PKWareExtraHeader {
             }
             // TODO: these offsets look even more suspicious, the constant should likely be 28 rather than 22
             assertDynamicLengthFits("vSize", vSize, ivSize + 22 + erdSize + resize, length);
-            // TODO: use Arrays.copyOfRange
-            this.vData = new byte[vSize - 4];
-            this.vCRC32 = new byte[4];
-            System.arraycopy(data, offset + ivSize + 22 + erdSize + resize, this.vData, 0, vSize - 4);
-            System.arraycopy(data, offset + ivSize + 22 + erdSize + resize + vSize - 4, vCRC32, 0, 4);
+            //
+            this.vData = Arrays.copyOfRange(data, offset + ivSize + 22 + erdSize + resize, vSize - 4);
+            this.vCRC32 = Arrays.copyOfRange(data, offset + ivSize + 22 + erdSize + resize + vSize - 4, 4);
         }
 
         // validate values?


[commons-compress] 02/02: Format tweaks

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 382d302657eadeaaafea04d8bcac335addedfc58
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Dec 27 17:32:32 2022 -0500

    Format tweaks
---
 .../org/apache/commons/compress/archivers/zip/PKWareExtraHeader.java     | 1 +
 .../commons/compress/archivers/zip/X0015_CertificateIdForFile.java       | 1 +
 .../commons/compress/archivers/zip/X0017_StrongEncryptionHeader.java     | 1 +
 3 files changed, 3 insertions(+)

diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/PKWareExtraHeader.java b/src/main/java/org/apache/commons/compress/archivers/zip/PKWareExtraHeader.java
index 913173ec..30810100 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/PKWareExtraHeader.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/PKWareExtraHeader.java
@@ -123,6 +123,7 @@ public abstract class PKWareExtraHeader implements ZipExtraField {
             return code;
         }
     }
+
     /**
      * Hash Algorithm
      *
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/X0015_CertificateIdForFile.java b/src/main/java/org/apache/commons/compress/archivers/zip/X0015_CertificateIdForFile.java
index 1263b038..912e21bf 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/X0015_CertificateIdForFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/X0015_CertificateIdForFile.java
@@ -48,6 +48,7 @@ public class X0015_CertificateIdForFile extends PKWareExtraHeader {
     private int rcount;
 
     private HashAlgorithm hashAlg;
+
     public X0015_CertificateIdForFile() {
         super(new ZipShort(0x0015));
     }
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/X0017_StrongEncryptionHeader.java b/src/main/java/org/apache/commons/compress/archivers/zip/X0017_StrongEncryptionHeader.java
index 3c75a40f..64c36999 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/X0017_StrongEncryptionHeader.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/X0017_StrongEncryptionHeader.java
@@ -267,6 +267,7 @@ public class X0017_StrongEncryptionHeader extends PKWareExtraHeader {
     private byte[] vData;
 
     private byte[] vCRC32;
+
     public X0017_StrongEncryptionHeader() {
         super(new ZipShort(0x0017));
     }