From 955797a09048ee7497ca734c20626d3af5378404 Mon Sep 17 00:00:00 2001 From: steckbrief Date: Wed, 4 Jan 2017 21:42:16 +0100 Subject: Fixed NPE in FileParams.setKeyAndIv --- .../conversationsplus/entities/FileParams.java | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/FileParams.java b/src/main/java/de/thedevstack/conversationsplus/entities/FileParams.java index 290b87b8..3abb37e4 100644 --- a/src/main/java/de/thedevstack/conversationsplus/entities/FileParams.java +++ b/src/main/java/de/thedevstack/conversationsplus/entities/FileParams.java @@ -93,17 +93,19 @@ public class FileParams { } public void setKeyAndIv(byte[] keyIvCombo) { - if (keyIvCombo.length == 48) { - this.aeskey = new byte[32]; - this.iv = new byte[16]; - System.arraycopy(keyIvCombo, 0, this.iv, 0, 16); - System.arraycopy(keyIvCombo, 16, this.aeskey, 0, 32); - } else if (keyIvCombo.length >= 32) { - this.aeskey = new byte[32]; - System.arraycopy(keyIvCombo, 0, aeskey, 0, 32); - } else if (keyIvCombo.length >= 16) { - this.aeskey = new byte[16]; - System.arraycopy(keyIvCombo, 0, this.aeskey, 0, 16); + if (null != keyIvCombo) { + if (keyIvCombo.length == 48) { + this.aeskey = new byte[32]; + this.iv = new byte[16]; + System.arraycopy(keyIvCombo, 0, this.iv, 0, 16); + System.arraycopy(keyIvCombo, 16, this.aeskey, 0, 32); + } else if (keyIvCombo.length >= 32) { + this.aeskey = new byte[32]; + System.arraycopy(keyIvCombo, 0, aeskey, 0, 32); + } else if (keyIvCombo.length >= 16) { + this.aeskey = new byte[16]; + System.arraycopy(keyIvCombo, 0, this.aeskey, 0, 16); + } } } -- cgit v1.2.3