mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 07:58:34 +00:00
Prevent ZkGroup link crashes.
This commit is contained in:
parent
8861ad76ed
commit
4de86cb6cf
@ -4,7 +4,7 @@ import androidx.annotation.NonNull;
|
||||
|
||||
public final class BadGroupIdException extends Exception {
|
||||
|
||||
BadGroupIdException() {
|
||||
public BadGroupIdException() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,6 @@ import org.thoughtcrime.securesms.util.RemoteDeleteUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.libsignal.state.SessionStore;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.libsignal.util.guava.Preconditions;
|
||||
import org.whispersystems.signalservice.api.groupsv2.InvalidGroupStateException;
|
||||
import org.whispersystems.signalservice.api.groupsv2.NoCredentialForRedemptionTimeException;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
||||
@ -413,9 +412,13 @@ public final class PushProcessMessageJob extends BaseJob {
|
||||
Log.w(TAG, e);
|
||||
handleCorruptMessage(e.getSender(), e.getSenderDevice(), timestamp, smsMessageId);
|
||||
} catch (BadGroupIdException e) {
|
||||
if (!FeatureFlags.ZK_GROUPS) {
|
||||
Log.w(TAG, "Ignoring message with GV2 - no ZK_GROUP library", e);
|
||||
} else {
|
||||
Log.w(TAG, "Ignoring message with bad group id", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to update the group to the version mentioned in the message.
|
||||
|
@ -13,6 +13,7 @@ import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.groupsv2.NoCredentialForRedemptionTimeException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException;
|
||||
@ -72,6 +73,11 @@ public final class RequestGroupV2InfoJob extends BaseJob {
|
||||
|
||||
@Override
|
||||
public void onRun() throws IOException, GroupNotAMemberException, GroupChangeBusyException {
|
||||
if (!FeatureFlags.groupsV2()) {
|
||||
Log.w(TAG, "Group update skipped due to feature flag " + groupId);
|
||||
return;
|
||||
}
|
||||
|
||||
Log.i(TAG, "Updating group to revision " + toRevision);
|
||||
|
||||
Optional<GroupDatabase.GroupRecord> group = DatabaseFactory.getGroupDatabase(context).getGroup(groupId);
|
||||
|
@ -507,4 +507,7 @@ public final class FeatureFlags {
|
||||
|
||||
/** Read and write versioned profile information. */
|
||||
public static final boolean VERSIONED_PROFILES = org.whispersystems.signalservice.FeatureFlags.VERSIONED_PROFILES;
|
||||
|
||||
/** Enabled ZKGroups library. */
|
||||
public static final boolean ZK_GROUPS = org.whispersystems.signalservice.FeatureFlags.ZK_GROUPS;
|
||||
}
|
||||
|
@ -41,6 +41,9 @@ public final class GroupUtil {
|
||||
if (groupContext.getGroupV1().isPresent()) {
|
||||
return GroupId.v1(groupContext.getGroupV1().get().getGroupId());
|
||||
} else if (groupContext.getGroupV2().isPresent()) {
|
||||
if (!FeatureFlags.ZK_GROUPS) {
|
||||
throw new BadGroupIdException();
|
||||
}
|
||||
return GroupId.v2(groupContext.getGroupV2().get().getMasterKey());
|
||||
} else {
|
||||
throw new AssertionError();
|
||||
|
Loading…
x
Reference in New Issue
Block a user