kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix crash when receiving call with no corresponding identity key.
rodzic
a1457d22d6
commit
214cb25d1b
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue