Null check for cipher text to prevent NPE on decryption

Fixes #1703
Closes #1728
// FREEBIE
This commit is contained in:
McLoo 2014-07-22 23:17:00 +02:00 committed by Moxie Marlinspike
parent 530ad7bc86
commit acc7c4c1c6

View File

@ -24,13 +24,13 @@ import android.util.Pair;
import org.thoughtcrime.securesms.crypto.AsymmetricMasterCipher;
import org.thoughtcrime.securesms.crypto.AsymmetricMasterSecret;
import org.whispersystems.textsecure.crypto.InvalidMessageException;
import org.whispersystems.textsecure.crypto.MasterCipher;
import org.whispersystems.textsecure.crypto.MasterSecret;
import org.thoughtcrime.securesms.database.model.DisplayRecord;
import org.thoughtcrime.securesms.sms.IncomingTextMessage;
import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
import org.thoughtcrime.securesms.util.LRUCache;
import org.whispersystems.textsecure.crypto.InvalidMessageException;
import org.whispersystems.textsecure.crypto.MasterCipher;
import org.whispersystems.textsecure.crypto.MasterSecret;
import java.lang.ref.SoftReference;
import java.util.Collections;
@ -145,6 +145,10 @@ public class EncryptingSmsDatabase extends SmsDatabase {
long type = cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.TYPE));
String ciphertext = cursor.getString(cursor.getColumnIndexOrThrow(SmsDatabase.BODY));
if (ciphertext == null) {
return new DisplayRecord.Body("", true);
}
try {
if (SmsDatabase.Types.isSymmetricEncryption(type)) {
String plaintext = plaintextCache.get(ciphertext);