aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi/poifs/crypt
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2018-05-21 23:17:57 +0000
committerAndreas Beeker <kiwiwings@apache.org>2018-05-21 23:17:57 +0000
commitd136eaa77889159fb88f9761aaeb469f45398735 (patch)
treee38fdacaad77cdeff6429952df80bee23d97c3d9 /src/java/org/apache/poi/poifs/crypt
parentd3fbc56fd0eca832545e4dc923d40a85aa97937b (diff)
downloadpoi-d136eaa77889159fb88f9761aaeb469f45398735.tar.gz
poi-d136eaa77889159fb88f9761aaeb469f45398735.zip
sonar fixes - null dereference
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1831992 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/poifs/crypt')
-rw-r--r--src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java10
-rw-r--r--src/java/org/apache/poi/poifs/crypt/xor/XOREncryptor.java8
2 files changed, 13 insertions, 5 deletions
diff --git a/src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java b/src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java
index 62835109eb..844b5d2266 100644
--- a/src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java
+++ b/src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java
@@ -218,9 +218,13 @@ public abstract class ChunkedCipherOutputStream extends FilterOutputStream {
int ciLen = (doFinal)
? cipher.doFinal(chunk, 0, posInChunk, chunk)
: cipher.update(chunk, 0, posInChunk, chunk);
-
- for (int i = plainByteFlags.nextSetBit(0); i >= 0 && i < posInChunk; i = plainByteFlags.nextSetBit(i+1)) {
- chunk[i] = plain[i];
+
+ if (plain != null) {
+ int i = plainByteFlags.nextSetBit(0);
+ while (i >= 0 && i < posInChunk) {
+ chunk[i] = plain[i];
+ i = plainByteFlags.nextSetBit(i+1);
+ }
}
return ciLen;
diff --git a/src/java/org/apache/poi/poifs/crypt/xor/XOREncryptor.java b/src/java/org/apache/poi/poifs/crypt/xor/XOREncryptor.java
index c090fe3610..61f06f2632 100644
--- a/src/java/org/apache/poi/poifs/crypt/xor/XOREncryptor.java
+++ b/src/java/org/apache/poi/poifs/crypt/xor/XOREncryptor.java
@@ -164,8 +164,12 @@ public class XOREncryptor extends Encryptor implements Cloneable {
chunk[i] = value;
}
- for (int i = plainBytes.nextSetBit(start); i >= 0 && i < posInChunk; i = plainBytes.nextSetBit(i+1)) {
- chunk[i] = plain[i];
+ if (plain != null) {
+ int i = plainBytes.nextSetBit(start);
+ while (i >= 0 && i < posInChunk) {
+ chunk[i] = plain[i];
+ i = plainBytes.nextSetBit(i + 1);
+ }
}
return posInChunk;