You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2017/10/25 11:21:45 UTC

[cxf] branch master updated: Preventing a possible NPE in JweOutputStream

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

sergeyb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new ba1fa12  Preventing a possible NPE in JweOutputStream
ba1fa12 is described below

commit ba1fa120af2d45ab601c3da46d47224dfd5e567c
Author: Sergey Beryozkin <sb...@gmail.com>
AuthorDate: Wed Oct 25 12:21:30 2017 +0100

    Preventing a possible NPE in JweOutputStream
---
 .../java/org/apache/cxf/rs/security/jose/jwe/JweOutputStream.java | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweOutputStream.java b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweOutputStream.java
index 6076ee9..f9da335 100644
--- a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweOutputStream.java
+++ b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jwe/JweOutputStream.java
@@ -79,10 +79,12 @@ public class JweOutputStream extends FilterOutputStream {
 
     private void encryptAndWrite(byte[] chunk, int off, int len) throws IOException {
         byte[] encrypted = encryptingCipher.update(chunk, off, len);
-        if (authTagProducer != null) {
-            authTagProducer.update(encrypted, 0, encrypted.length);
+        if (encrypted != null) {
+            if (authTagProducer != null) {
+                authTagProducer.update(encrypted, 0, encrypted.length);
+            }
+            encodeAndWrite(encrypted, 0, encrypted.length, false);
         }
-        encodeAndWrite(encrypted, 0, encrypted.length, false);
     }
     private void encodeAndWrite(byte[] encryptedChunk, int off, int len, boolean finalWrite) throws IOException {
         byte[] theChunk = lastEncryptedDataChunk;

-- 
To stop receiving notification emails like this one, please contact
['"commits@cxf.apache.org" <co...@cxf.apache.org>'].