No secure calls to yourself.

Fixes #4156
// FREEBIE
This commit is contained in:
Moxie Marlinspike 2015-10-01 11:14:00 -07:00
parent 003787e4a6
commit 1fd8025cb5

View File

@ -121,6 +121,7 @@ import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.concurrent.ListenableFuture; import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
import org.thoughtcrime.securesms.util.concurrent.SettableFuture; import org.thoughtcrime.securesms.util.concurrent.SettableFuture;
import org.whispersystems.libaxolotl.InvalidMessageException; import org.whispersystems.libaxolotl.InvalidMessageException;
import org.whispersystems.textsecure.api.util.InvalidNumberException;
import java.io.IOException; import java.io.IOException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
@ -772,7 +773,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
} }
return new Pair<>(capabilities.getTextCapability() == Capability.SUPPORTED, return new Pair<>(capabilities.getTextCapability() == Capability.SUPPORTED,
capabilities.getVoiceCapability() == Capability.SUPPORTED); capabilities.getVoiceCapability() == Capability.SUPPORTED &&
!isSelfConversation());
} catch (IOException e) { } catch (IOException e) {
Log.w(TAG, e); Log.w(TAG, e);
return new Pair<>(false, false); return new Pair<>(false, false);
@ -1112,6 +1114,20 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
} }
} }
private boolean isSelfConversation() {
try {
if (!TextSecurePreferences.isPushRegistered(this)) return false;
if (!recipients.isSingleRecipient()) return false;
if (recipients.getPrimaryRecipient().isGroupRecipient()) return false;
return Util.canonicalizeNumber(this, recipients.getPrimaryRecipient().getNumber())
.equals(TextSecurePreferences.getLocalNumber(this));
} catch (InvalidNumberException e) {
Log.w(TAG, e);
return false;
}
}
private boolean isGroupConversation() { private boolean isGroupConversation() {
return getRecipients() != null && return getRecipients() != null &&
(!getRecipients().isSingleRecipient() || getRecipients().isGroupRecipient()); (!getRecipients().isSingleRecipient() || getRecipients().isGroupRecipient());