Fix crash when receiving call with no corresponding identity key.

fork-5.53.8
Cody Henthorne 2021-02-17 10:26:45 -05:00 zatwierdzone przez GitHub
rodzic a1457d22d6
commit 214cb25d1b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
5 zmienionych plików z 31 dodań i 10 usunięć

Wyświetl plik

@ -518,6 +518,7 @@ public class WebRtcCallActivity extends BaseActivity implements SafetyNumberChan
final Recipient recipient = event.getRemoteParticipants().get(0).getRecipient();
if (theirKey == null) {
Log.w(TAG, "Untrusted identity without an identity key, terminating call.");
handleTerminate(recipient, HangupMessage.Type.NORMAL);
}

Wyświetl plik

@ -19,6 +19,9 @@ package org.thoughtcrime.securesms.crypto;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.Nullable;
import org.thoughtcrime.securesms.util.ParcelUtil;
import org.whispersystems.libsignal.IdentityKey;
import org.whispersystems.libsignal.InvalidKeyException;
@ -40,19 +43,17 @@ public class IdentityKeyParcelable implements Parcelable {
private final IdentityKey identityKey;
public IdentityKeyParcelable(IdentityKey identityKey) {
public IdentityKeyParcelable(@Nullable IdentityKey identityKey) {
this.identityKey = identityKey;
}
public IdentityKeyParcelable(Parcel in) throws InvalidKeyException {
int serializedLength = in.readInt();
byte[] serialized = new byte[serializedLength];
byte[] serialized = ParcelUtil.readByteArray(in);
in.readByteArray(serialized);
this.identityKey = new IdentityKey(serialized, 0);
this.identityKey = serialized != null ? new IdentityKey(serialized, 0) : null;
}
public IdentityKey get() {
public @Nullable IdentityKey get() {
return identityKey;
}
@ -63,7 +64,6 @@ public class IdentityKeyParcelable implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(identityKey.serialize().length);
dest.writeByteArray(identityKey.serialize());
ParcelUtil.writeByteArray(dest, identityKey != null ? identityKey.serialize() : null);
}
}

Wyświetl plik

@ -85,7 +85,7 @@ public final class CallParticipant {
this.deviceOrdinal = deviceOrdinal;
}
public @NonNull CallParticipant withIdentityKey(@NonNull IdentityKey identityKey) {
public @NonNull CallParticipant withIdentityKey(@Nullable IdentityKey identityKey) {
return new CallParticipant(callParticipantId, recipient, identityKey, videoSink, cameraState, videoEnabled, microphoneEnabled, lastSpoke, mediaKeysReceived, addedToCallTime, deviceOrdinal);
}

Wyświetl plik

@ -533,7 +533,7 @@ public abstract class WebRtcActionProcessor {
if (errorCallState == WebRtcViewModel.State.UNTRUSTED_IDENTITY) {
CallParticipant participant = Objects.requireNonNull(currentState.getCallInfoState().getRemoteCallParticipant(activePeer.getRecipient()));
CallParticipant untrusted = participant.withIdentityKey(identityKey.get());
CallParticipant untrusted = participant.withIdentityKey(identityKey.orNull());
builder.changeCallInfoState()
.callState(WebRtcViewModel.State.UNTRUSTED_IDENTITY)

Wyświetl plik

@ -4,6 +4,7 @@ import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
@ -59,4 +60,23 @@ public class ParcelUtil {
public static boolean readBoolean(@NonNull Parcel in) {
return in.readByte() != 0;
}
public static void writeByteArray(@NonNull Parcel dest, @Nullable byte[] data) {
if (data == null) {
dest.writeInt(-1);
} else {
dest.writeInt(data.length);
dest.writeByteArray(data);
}
}
public static @Nullable byte[] readByteArray(@NonNull Parcel in) {
int length = in.readInt();
if (length == -1) {
return null;
}
byte[] data = new byte[length];
in.readByteArray(data);
return data;
}
}