]> source.dussan.org Git - poi.git/commitdiff
Sonar fixes, direct array parameter
authorAndreas Beeker <kiwiwings@apache.org>
Tue, 1 Dec 2015 00:23:21 +0000 (00:23 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Tue, 1 Dec 2015 00:23:21 +0000 (00:23 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1717359 13f79535-47bb-0310-9956-ffa450edef68

12 files changed:
src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java
src/java/org/apache/poi/poifs/crypt/Decryptor.java
src/java/org/apache/poi/poifs/crypt/EncryptionHeader.java
src/java/org/apache/poi/poifs/crypt/EncryptionVerifier.java
src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionHeader.java
src/ooxml/java/org/apache/poi/poifs/crypt/dsig/DigestInfo.java
src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextPFException9.java
src/scratchpad/src/org/apache/poi/hslf/record/RecordContainer.java
src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java
src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java
src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java

index f64bf23c7c6c1c06bc86f4dec5374835e2d67530..923d7075ff55c4ef08d2f057773f602603a2289c 100644 (file)
@@ -91,7 +91,7 @@ public class DataSpaceMapUtils {
         DataSpaceMapEntry entries[];\r
         \r
         public DataSpaceMap(DataSpaceMapEntry entries[]) {\r
-            this.entries = entries;\r
+            this.entries = entries.clone();\r
         }\r
         \r
         public DataSpaceMap(LittleEndianInput is) {\r
@@ -113,13 +113,13 @@ public class DataSpaceMapUtils {
     }\r
     \r
     public static class DataSpaceMapEntry implements EncryptionRecord {\r
-        int referenceComponentType[];\r
-        String referenceComponent[];\r
-        String dataSpaceName;\r
+        final int referenceComponentType[];\r
+        final String referenceComponent[];\r
+        final String dataSpaceName;\r
         \r
         public DataSpaceMapEntry(int referenceComponentType[], String referenceComponent[], String dataSpaceName) {\r
-            this.referenceComponentType = referenceComponentType;\r
-            this.referenceComponent = referenceComponent;\r
+            this.referenceComponentType = referenceComponentType.clone();\r
+            this.referenceComponent = referenceComponent.clone();\r
             this.dataSpaceName = dataSpaceName;\r
         }\r
         \r
@@ -152,7 +152,7 @@ public class DataSpaceMapUtils {
         String transformer[];\r
         \r
         public DataSpaceDefinition(String transformer[]) {\r
-            this.transformer = transformer;\r
+            this.transformer = transformer.clone();\r
         }\r
         \r
         public DataSpaceDefinition(LittleEndianInput is) {\r
index eb94dca983b0fd34f8252e691f2472de9ffc76d9..bec436a88e9c9a443e86b1e7d6ea62ed30128287 100644 (file)
@@ -114,15 +114,15 @@ public abstract class Decryptor {
     }
 
     protected void setVerifier(byte[] verifier) {
-        this.verifier = verifier;
+        this.verifier = (verifier == null) ? null : verifier.clone();
     }
 
     protected void setIntegrityHmacKey(byte[] integrityHmacKey) {
-        this.integrityHmacKey = integrityHmacKey;
+        this.integrityHmacKey = (integrityHmacKey == null) ? null : integrityHmacKey.clone();
     }
 
     protected void setIntegrityHmacValue(byte[] integrityHmacValue) {
-        this.integrityHmacValue = integrityHmacValue;
+        this.integrityHmacValue = (integrityHmacValue == null) ? null : integrityHmacValue.clone();
     }
 
     protected int getBlockSizeInBytes() {
index adcf4c4275ad9f13d8d6016ac2d1dfa9d12eb8ad..b326b52a1a280838f78b4d29301133252bc0678b 100644 (file)
@@ -135,7 +135,7 @@ public abstract class EncryptionHeader {
     }
     
     protected void setKeySalt(byte salt[]) {
-        this.keySalt = salt;
+        this.keySalt = (salt == null) ? null : salt.clone();
     }
 
     /**
index 9dafc11bf705382b58b11e99b44fd8751a2c321a..a782063e774eae558a62cae7a4e081f0f1fa8f99 100644 (file)
@@ -100,19 +100,19 @@ public abstract class EncryptionVerifier {
     }
 
     protected void setSalt(byte[] salt) {
-        this.salt = salt;
+        this.salt = (salt == null) ? null : salt.clone();
     }
 
     protected void setEncryptedVerifier(byte[] encryptedVerifier) {
-        this.encryptedVerifier = encryptedVerifier;
+        this.encryptedVerifier = (encryptedVerifier == null) ? null : encryptedVerifier.clone();
     }
 
     protected void setEncryptedVerifierHash(byte[] encryptedVerifierHash) {
-        this.encryptedVerifierHash = encryptedVerifierHash;
+        this.encryptedVerifierHash = (encryptedVerifierHash == null) ? null : encryptedVerifierHash.clone();
     }
 
     protected void setEncryptedKey(byte[] encryptedKey) {
-        this.encryptedKey = encryptedKey;
+        this.encryptedKey = (encryptedKey == null) ? null : encryptedKey.clone();
     }
 
     protected void setSpinCount(int spinCount) {
index de953b8db13aad978494863fdf77bc7758ac0243..a5fb144282053de2914a84cc64d5802df819e818 100644 (file)
@@ -111,7 +111,7 @@ public class AgileEncryptionHeader extends EncryptionHeader {
     }\r
 \r
     protected void setEncryptedHmacKey(byte[] encryptedHmacKey) {\r
-        this.encryptedHmacKey = encryptedHmacKey;\r
+        this.encryptedHmacKey = (encryptedHmacKey == null) ? null : encryptedHmacKey.clone();\r
     }\r
 \r
     public byte[] getEncryptedHmacValue() {\r
@@ -119,6 +119,6 @@ public class AgileEncryptionHeader extends EncryptionHeader {
     }\r
 \r
     protected void setEncryptedHmacValue(byte[] encryptedHmacValue) {\r
-        this.encryptedHmacValue = encryptedHmacValue;\r
+        this.encryptedHmacValue = (encryptedHmacValue == null) ? null : encryptedHmacValue.clone();\r
     }\r
 }\r
index be57370c5d685891251f85a278712fc6408f5748..33ae03c68df5a0c4328e99f3a35d5939499e8fbe 100644 (file)
@@ -43,7 +43,7 @@ public class DigestInfo implements Serializable {
      * @param description\r
      */\r
     public DigestInfo(byte[] digestValue, HashAlgorithm hashAlgo, String description) {\r
-        this.digestValue = digestValue;\r
+        this.digestValue = digestValue.clone();\r
         this.hashAlgo = hashAlgo;\r
         this.description = description;\r
     }\r
index 262a845f5127a12ac3392ffd1a87c1cb71a351ad..128bc836536e3a69a600a7937437b126ac0ac825 100644 (file)
@@ -46,7 +46,7 @@ public class TextPFException9 {
        private final Short autoNumberStartNumber;
        private final static Short DEFAULT_START_NUMBER = 1;
        private final int recordLength;
-       public TextPFException9(final byte[] source, final int startIndex) {
+       public TextPFException9(final byte[] source, final int startIndex) { // NOSONAR
                //this.mask1 = source[startIndex];
                //this.mask2 = source[startIndex + 1];
                this.mask3 = source[startIndex + 2];
index a25ca605c2b3d21abef27e71e414180dde7f03ae..28bc7bbf0af601e222c99278eb38d403d3f8b8e9 100644 (file)
@@ -247,7 +247,7 @@ public abstract class RecordContainer extends Record
      * @param records   the new child records
      */
     public void setChildRecord(Record[] records) {
-        this._children = records;
+        this._children = records.clone();
     }
 
        /* ===============================================================
index 195b59c08f43a3ad4814525677902449d255c3da..ef5131708d07d6244d3acca91473d2d0561d7620 100644 (file)
@@ -153,12 +153,16 @@ public final class SlideListWithText extends RecordContainer {
        /**
         * Get access to the SlideAtomsSets of the children of this record
         */
-       public SlideAtomsSet[] getSlideAtomsSets() { return slideAtomsSets; }
+       public SlideAtomsSet[] getSlideAtomsSets() {
+           return slideAtomsSets;
+    }
 
        /**
        * Get access to the SlideAtomsSets of the children of this record
        */
-       public void setSlideAtomsSets( SlideAtomsSet[] sas ) { slideAtomsSets = sas; }
+       public void setSlideAtomsSets( SlideAtomsSet[] sas ) {
+           slideAtomsSets = sas.clone();
+    }
 
        /**
         * Return the value we were given at creation
index 6782def529b17c3dd2b9145e8ef5523990e15118..df0b323f2cea2a2051d5121ae7b64e629cb2b129 100644 (file)
 
 package org.apache.poi.hslf.record;
 
-import java.io.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.poi.hslf.exceptions.HSLFException;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.LittleEndianByteArrayInputStream;
 
@@ -136,7 +139,7 @@ public final class TextSpecInfoAtom extends RecordAtom {
             try {
                 run.writeOut(bos);
             } catch (IOException e) {
-                throw new RuntimeException(e);
+                throw new HSLFException(e);
             }
         }
         _data = bos.toByteArray();
index 0e2f7301cea8ddee4a982eae9344fd1a7a467587..7b4150a4fa717b8b9e086efa1935f98b61a5de7b 100644 (file)
@@ -305,7 +305,7 @@ public class TextSpecInfoRun {
      * @param smartTagsBytes the unparsed smart tags, null to unset\r
      */\r
     public void setSmartTagsBytes(byte[] smartTagsBytes) {\r
-        this.smartTagsBytes = smartTagsBytes;\r
+        this.smartTagsBytes = (smartTagsBytes == null) ? null : smartTagsBytes.clone();\r
         mask = smartTagFld.setBoolean(mask, smartTagsBytes != null);\r
     }\r
     \r
index 7c5fc5179e01d9d7e0eaf5447e65371a149d0b44..199ada8fcf3bebf89534f6e255ce1b29b2f4b8dd 100644 (file)
@@ -84,7 +84,7 @@ public abstract class HSLFPictureData implements PictureData {
     }
 
     public void setRawData(byte[] data){
-        rawdata = data;
+        rawdata = (data == null) ? null : data.clone();
     }
 
     /**