aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2015-12-01 00:23:21 +0000
committerAndreas Beeker <kiwiwings@apache.org>2015-12-01 00:23:21 +0000
commit98ac10e52191f5fd4238aff395ebe57f1110f1dc (patch)
tree9c92b990deb3b303bb6ac6feb0398484abb3147f
parent96c3abad1a02b9e6e883ac3b1b5c8804812e4eb3 (diff)
downloadpoi-98ac10e52191f5fd4238aff395ebe57f1110f1dc.tar.gz
poi-98ac10e52191f5fd4238aff395ebe57f1110f1dc.zip
Sonar fixes, direct array parameter
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1717359 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java14
-rw-r--r--src/java/org/apache/poi/poifs/crypt/Decryptor.java6
-rw-r--r--src/java/org/apache/poi/poifs/crypt/EncryptionHeader.java2
-rw-r--r--src/java/org/apache/poi/poifs/crypt/EncryptionVerifier.java8
-rw-r--r--src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionHeader.java4
-rw-r--r--src/ooxml/java/org/apache/poi/poifs/crypt/dsig/DigestInfo.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextPFException9.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/record/RecordContainer.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java8
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java7
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java2
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java2
12 files changed, 33 insertions, 26 deletions
diff --git a/src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java b/src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java
index f64bf23c7c..923d7075ff 100644
--- a/src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java
+++ b/src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java
@@ -91,7 +91,7 @@ public class DataSpaceMapUtils {
DataSpaceMapEntry entries[];
public DataSpaceMap(DataSpaceMapEntry entries[]) {
- this.entries = entries;
+ this.entries = entries.clone();
}
public DataSpaceMap(LittleEndianInput is) {
@@ -113,13 +113,13 @@ public class DataSpaceMapUtils {
}
public static class DataSpaceMapEntry implements EncryptionRecord {
- int referenceComponentType[];
- String referenceComponent[];
- String dataSpaceName;
+ final int referenceComponentType[];
+ final String referenceComponent[];
+ final String dataSpaceName;
public DataSpaceMapEntry(int referenceComponentType[], String referenceComponent[], String dataSpaceName) {
- this.referenceComponentType = referenceComponentType;
- this.referenceComponent = referenceComponent;
+ this.referenceComponentType = referenceComponentType.clone();
+ this.referenceComponent = referenceComponent.clone();
this.dataSpaceName = dataSpaceName;
}
@@ -152,7 +152,7 @@ public class DataSpaceMapUtils {
String transformer[];
public DataSpaceDefinition(String transformer[]) {
- this.transformer = transformer;
+ this.transformer = transformer.clone();
}
public DataSpaceDefinition(LittleEndianInput is) {
diff --git a/src/java/org/apache/poi/poifs/crypt/Decryptor.java b/src/java/org/apache/poi/poifs/crypt/Decryptor.java
index eb94dca983..bec436a88e 100644
--- a/src/java/org/apache/poi/poifs/crypt/Decryptor.java
+++ b/src/java/org/apache/poi/poifs/crypt/Decryptor.java
@@ -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() {
diff --git a/src/java/org/apache/poi/poifs/crypt/EncryptionHeader.java b/src/java/org/apache/poi/poifs/crypt/EncryptionHeader.java
index adcf4c4275..b326b52a1a 100644
--- a/src/java/org/apache/poi/poifs/crypt/EncryptionHeader.java
+++ b/src/java/org/apache/poi/poifs/crypt/EncryptionHeader.java
@@ -135,7 +135,7 @@ public abstract class EncryptionHeader {
}
protected void setKeySalt(byte salt[]) {
- this.keySalt = salt;
+ this.keySalt = (salt == null) ? null : salt.clone();
}
/**
diff --git a/src/java/org/apache/poi/poifs/crypt/EncryptionVerifier.java b/src/java/org/apache/poi/poifs/crypt/EncryptionVerifier.java
index 9dafc11bf7..a782063e77 100644
--- a/src/java/org/apache/poi/poifs/crypt/EncryptionVerifier.java
+++ b/src/java/org/apache/poi/poifs/crypt/EncryptionVerifier.java
@@ -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) {
diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionHeader.java b/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionHeader.java
index de953b8db1..a5fb144282 100644
--- a/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionHeader.java
+++ b/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionHeader.java
@@ -111,7 +111,7 @@ public class AgileEncryptionHeader extends EncryptionHeader {
}
protected void setEncryptedHmacKey(byte[] encryptedHmacKey) {
- this.encryptedHmacKey = encryptedHmacKey;
+ this.encryptedHmacKey = (encryptedHmacKey == null) ? null : encryptedHmacKey.clone();
}
public byte[] getEncryptedHmacValue() {
@@ -119,6 +119,6 @@ public class AgileEncryptionHeader extends EncryptionHeader {
}
protected void setEncryptedHmacValue(byte[] encryptedHmacValue) {
- this.encryptedHmacValue = encryptedHmacValue;
+ this.encryptedHmacValue = (encryptedHmacValue == null) ? null : encryptedHmacValue.clone();
}
}
diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/DigestInfo.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/DigestInfo.java
index be57370c5d..33ae03c68d 100644
--- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/DigestInfo.java
+++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/DigestInfo.java
@@ -43,7 +43,7 @@ public class DigestInfo implements Serializable {
* @param description
*/
public DigestInfo(byte[] digestValue, HashAlgorithm hashAlgo, String description) {
- this.digestValue = digestValue;
+ this.digestValue = digestValue.clone();
this.hashAlgo = hashAlgo;
this.description = description;
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextPFException9.java b/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextPFException9.java
index 262a845f51..128bc83653 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextPFException9.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextPFException9.java
@@ -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];
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/RecordContainer.java b/src/scratchpad/src/org/apache/poi/hslf/record/RecordContainer.java
index a25ca605c2..28bc7bbf0a 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/RecordContainer.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/RecordContainer.java
@@ -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();
}
/* ===============================================================
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java b/src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java
index 195b59c08f..ef5131708d 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java
@@ -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
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java b/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java
index 6782def529..df0b323f2c 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java
@@ -17,10 +17,13 @@
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();
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java b/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java
index 0e2f7301ce..7b4150a4fa 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java
@@ -305,7 +305,7 @@ public class TextSpecInfoRun {
* @param smartTagsBytes the unparsed smart tags, null to unset
*/
public void setSmartTagsBytes(byte[] smartTagsBytes) {
- this.smartTagsBytes = smartTagsBytes;
+ this.smartTagsBytes = (smartTagsBytes == null) ? null : smartTagsBytes.clone();
mask = smartTagFld.setBoolean(mask, smartTagsBytes != null);
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java
index 7c5fc5179e..199ada8fcf 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java
@@ -84,7 +84,7 @@ public abstract class HSLFPictureData implements PictureData {
}
public void setRawData(byte[] data){
- rawdata = data;
+ rawdata = (data == null) ? null : data.clone();
}
/**