Fix for NPE during a secure session with no sender identity key.

This commit is contained in:
Moxie Marlinspike 2012-08-07 19:03:00 -07:00
parent 3900808578
commit 5fb7ae7ecf

View File

@ -16,14 +16,6 @@
*/
package org.thoughtcrime.securesms.database;
import java.io.IOException;
import org.thoughtcrime.securesms.crypto.IdentityKey;
import org.thoughtcrime.securesms.crypto.InvalidKeyException;
import org.thoughtcrime.securesms.crypto.MasterCipher;
import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.util.Base64;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
@ -32,6 +24,14 @@ import android.database.sqlite.SQLiteOpenHelper;
import android.net.Uri;
import android.util.Log;
import org.thoughtcrime.securesms.crypto.IdentityKey;
import org.thoughtcrime.securesms.crypto.InvalidKeyException;
import org.thoughtcrime.securesms.crypto.MasterCipher;
import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.util.Base64;
import java.io.IOException;
public class IdentityDatabase extends Database {
private static final Uri CHANGE_URI = Uri.parse("content://textsecure/identities");
@ -61,6 +61,9 @@ public class IdentityDatabase extends Database {
}
public String getNameForIdentity(MasterSecret masterSecret, IdentityKey identityKey) {
if (identityKey == null)
return null;
MasterCipher masterCipher = new MasterCipher(masterSecret);
SQLiteDatabase database = databaseHelper.getReadableDatabase();
Cursor cursor = null;