]> source.dussan.org Git - poi.git/commitdiff
sonar fixes
authorAndreas Beeker <kiwiwings@apache.org>
Fri, 1 Jul 2016 21:10:40 +0000 (21:10 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Fri, 1 Jul 2016 21:10:40 +0000 (21:10 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751007 13f79535-47bb-0310-9956-ffa450edef68

13 files changed:
src/java/org/apache/poi/poifs/filesystem/Ole10Native.java
src/java/org/apache/poi/poifs/nio/ByteArrayBackedDataSource.java
src/java/org/apache/poi/poifs/storage/DataInputBlock.java
src/java/org/apache/poi/ss/formula/SheetRangeEvaluator.java
src/java/org/apache/poi/ss/usermodel/charts/DataSources.java
src/java/org/apache/poi/ss/util/SSCellRange.java
src/java/org/apache/poi/ss/util/SheetBuilder.java
src/java/org/apache/poi/util/LittleEndianByteArrayInputStream.java
src/java/org/apache/poi/util/LittleEndianByteArrayOutputStream.java
src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java
src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/Picture.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/PictureType.java

index 11f18a40a69b291e562e7b080ac41a9167b1779f..aee6747592cc22fb160ba27d109b948e32eadbe2 100644 (file)
@@ -393,6 +393,6 @@ public class Ole10Native {
     }\r
 \r
     public void setDataBuffer(byte dataBuffer[]) {\r
-        this.dataBuffer = dataBuffer;\r
+        this.dataBuffer = dataBuffer.clone();\r
     }\r
 }\r
index 6da40cd5ce089005e6598489f18999c0143f4338..88ee7da7f320fa8cf1f37b2892afdb4d2364288f 100644 (file)
@@ -28,7 +28,7 @@ public class ByteArrayBackedDataSource extends DataSource {
    private byte[] buffer;
    private long size;
    
-   public ByteArrayBackedDataSource(byte[] data, int size) {
+   public ByteArrayBackedDataSource(byte[] data, int size) { // NOSONAR
       this.buffer = data;
       this.size = size;
    }
index 2550d2d9100f6a6bb245577a2cb4a47cde64e2bb..0710b4ee73de6a058d08b926cee0629f7c8d7212 100644 (file)
@@ -47,7 +47,7 @@ public final class DataInputBlock {
        private int _readIndex;
        private int _maxIndex;
 
-       DataInputBlock(byte[] data, int startOffset) {
+       DataInputBlock(byte[] data, int startOffset) { // NOSONAR
                _buf = data;
                _readIndex = startOffset;
                _maxIndex = _buf.length;
index a69d76d145ce267c3db59446623acc8611fc0964..68dbb9be3ff64ead683f0bc1d4e8e90a80aaf18d 100644 (file)
@@ -36,7 +36,7 @@ final class SheetRangeEvaluator implements SheetRange {
         }
         _firstSheetIndex = firstSheetIndex;
         _lastSheetIndex = lastSheetIndex;
-        _sheetEvaluators = sheetEvaluators;
+        _sheetEvaluators = sheetEvaluators.clone();
        }
     public SheetRangeEvaluator(int onlySheetIndex, SheetRefEvaluator sheetEvaluator) {
         this(onlySheetIndex, onlySheetIndex, new SheetRefEvaluator[] {sheetEvaluator});
index bd786723401b70796a5320facddb6f552fa5e5f4..2f443814ee2a8db52e59f5754817d06113f6158d 100644 (file)
@@ -77,7 +77,7 @@ public class DataSources {
         private final T[] elements;
 
         public ArrayDataSource(T[] elements) {
-            this.elements = elements;
+            this.elements = elements.clone();
         }
 
         public int getPointCount() {
index 6a44a81f6bd4a88faf721fcea5f664ca87d92702..f58a2780e8e5a50909e3ddd2cc7fd343243edd17 100644 (file)
@@ -45,7 +45,7 @@ public final class SSCellRange<K extends Cell> implements CellRange<K> {
                _firstColumn = firstColumn;
                _height = height;
                _width = width;
-               _flattenedArray = flattenedArray;
+               _flattenedArray = flattenedArray.clone();
        }
 
        public static <B extends Cell> SSCellRange<B> create(int firstRow, int firstColumn, int height, int width, List<B> flattenedList, Class<B> cellClass) {
index 960d2d6ca207cd7f86165314f9c540bd8a23138f..366d783baf70348c1db0393bb6249b266a80fc3f 100644 (file)
@@ -40,7 +40,7 @@ public class SheetBuilder {
 
     public SheetBuilder(Workbook workbook, Object[][] cells) {
         this.workbook = workbook;
-        this.cells = cells;
+        this.cells = cells.clone();
     }
 
     /**
index 7f509396a64246cee906de8bd58e0e89115f2737..54388e151816eaa1a05a1bdb232d3806d53071a6 100644 (file)
@@ -27,7 +27,7 @@ public final class LittleEndianByteArrayInputStream implements LittleEndianInput
        private final int _endIndex;
        private int _readIndex;
 
-       public LittleEndianByteArrayInputStream(byte[] buf, int startOffset, int maxReadLen) {
+       public LittleEndianByteArrayInputStream(byte[] buf, int startOffset, int maxReadLen) { // NOSONAR
                _buf = buf;
                _readIndex = startOffset;
                _endIndex = startOffset + maxReadLen;
index 0320734b2d60023b4bfb73e8d6d38fb2f62b7d9a..081309cc2ea0a8b59a1831918fc5b0a1cacfd0f2 100644 (file)
@@ -29,7 +29,7 @@ public final class LittleEndianByteArrayOutputStream implements LittleEndianOutp
        private final int _endIndex;
        private int _writeIndex;
 
-       public LittleEndianByteArrayOutputStream(byte[] buf, int startOffset, int maxWriteLen) {
+       public LittleEndianByteArrayOutputStream(byte[] buf, int startOffset, int maxWriteLen) { // NOSONAR
                if (startOffset < 0 || startOffset > buf.length) {
                        throw new IllegalArgumentException("Specified startOffset (" + startOffset 
                                        + ") is out of allowable range (0.." + buf.length + ")");
index c6d307259eb8dc08588917e1492c20d2c2555cd2..c9601f1baa63ddeb0f1b12d97d9f156681c5bb86 100644 (file)
@@ -90,18 +90,18 @@ public class AgileEncryptor extends Encryptor {
         int keySize = builder.getHeader().getKeySize()/8;\r
         int hashSize = builder.getHeader().getHashAlgorithmEx().hashSize;\r
         \r
-        byte[] verifierSalt = new byte[blockSize]\r
-             , verifier = new byte[blockSize]\r
-             , keySalt = new byte[blockSize]\r
-             , keySpec = new byte[keySize]\r
-             , integritySalt = new byte[hashSize];\r
-        r.nextBytes(verifierSalt); // blocksize\r
-        r.nextBytes(verifier); // blocksize\r
-        r.nextBytes(keySalt); // blocksize\r
-        r.nextBytes(keySpec); // keysize\r
-        r.nextBytes(integritySalt); // hashsize\r
+        byte[] newVerifierSalt = new byte[blockSize]\r
+             , newVerifier = new byte[blockSize]\r
+             , newKeySalt = new byte[blockSize]\r
+             , newKeySpec = new byte[keySize]\r
+             , newIntegritySalt = new byte[hashSize];\r
+        r.nextBytes(newVerifierSalt); // blocksize\r
+        r.nextBytes(newVerifier); // blocksize\r
+        r.nextBytes(newKeySalt); // blocksize\r
+        r.nextBytes(newKeySpec); // keysize\r
+        r.nextBytes(newIntegritySalt); // hashsize\r
         \r
-        confirmPassword(password, keySpec, keySalt, verifierSalt, verifier, integritySalt);\r
+        confirmPassword(password, newKeySpec, newKeySalt, newVerifierSalt, newVerifier, newIntegritySalt);\r
     }\r
        \r
        public void confirmPassword(String password, byte keySpec[], byte keySalt[], byte verifier[], byte verifierSalt[], byte integritySalt[]) {\r
@@ -192,12 +192,12 @@ public class AgileEncryptor extends Encryptor {
          *    0xa0, 0x67, 0x7f, 0x02, 0xb2, 0x2c, 0x84, and 0x33.\r
          * 7.  Assign the encryptedHmacValue attribute to the base64-encoded form of the result of step 6. \r
          */\r
-        this.integritySalt = integritySalt;\r
+        this.integritySalt = integritySalt.clone();\r
 \r
         try {\r
             byte vec[] = CryptoFunctions.generateIv(hashAlgo, header.getKeySalt(), kIntegrityKeyBlock, header.getBlockSize());\r
             Cipher cipher = getCipher(secretKey, ver.getCipherAlgorithm(), ver.getChainingMode(), vec, Cipher.ENCRYPT_MODE);\r
-            byte filledSalt[] = getBlock0(integritySalt, getNextBlockSize(integritySalt.length, blockSize));\r
+            byte filledSalt[] = getBlock0(this.integritySalt, getNextBlockSize(this.integritySalt.length, blockSize));\r
             byte encryptedHmacKey[] = cipher.doFinal(filledSalt);\r
             header.setEncryptedHmacKey(encryptedHmacKey);\r
 \r
index ef5131708d07d6244d3acca91473d2d0561d7620..deeee6fe6b38d5f967f51f69c262d8c56192928d 100644 (file)
@@ -196,7 +196,7 @@ public final class SlideListWithText extends RecordContainer {
                /** Create one to hold the Records for one Slide's text */
                public SlideAtomsSet(SlidePersistAtom s, Record[] r) {
                        slidePersistAtom = s;
-                       slideRecords = r;
+                       slideRecords = r.clone();
                }
        }
 }
index 4a4ed2680f87cefa03562f79bf4b403f5e3dda19..108544efe7fe9ba169ac2625e519db1f5bbe5605 100644 (file)
@@ -107,9 +107,7 @@ public final class Picture
      * Builds a Picture object for a Picture stored in the
      *  DataStream
      */
-    public Picture( int dataBlockStartOfsset, byte[] _dataStream,
-            boolean fillBytes )
-    {
+    public Picture( int dataBlockStartOfsset, byte[] _dataStream, boolean fillBytes ) { // NOSONAR
         _picfAndOfficeArtData = new PICFAndOfficeArtData( _dataStream,
                 dataBlockStartOfsset );
         _picf = _picfAndOfficeArtData.getPicf();
@@ -584,10 +582,10 @@ public final class Picture
      */
     public void writeImageContent( OutputStream out ) throws IOException
     {
-        byte[] content = getContent();
-        if ( content != null && content.length > 0 )
+        byte[] c = getContent();
+        if ( c != null && c.length > 0 )
         {
-            out.write( content, 0, content.length );
+            out.write( c, 0, c.length );
         }
     }
 
index 18327d869389c9582e4a30356e73a668fe32a684..e630925dcd085ac0213aa9aa4bc2494ba6b34a6c 100644 (file)
@@ -78,7 +78,7 @@ public enum PictureType
     {
         this._mime = mime;
         this._extension = extension;
-        this._signatures = signatures;
+        this._signatures = signatures.clone();
     }
 
     public String getExtension()