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:22:46 UTC

[cxf] branch 3.1.x-fixes 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 3.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/3.1.x-fixes by this push:
     new f38ee98  Preventing a possible NPE in JweOutputStream
f38ee98 is described below

commit f38ee989c08603d272cb26c63853be0cc75ce580
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 1a0447d..f88a89b 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
@@ -80,10 +80,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>'].