Fix potential Base64 < 4 characters crash on group invite.
This commit is contained in:
parent
1d83729e6c
commit
f312757daf
2 changed files with 39 additions and 27 deletions
|
@ -1378,7 +1378,7 @@ public class ThreadDatabase extends Database {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable Extra getExtrasFor(MessageRecord record) {
|
private @Nullable Extra getExtrasFor(@NonNull MessageRecord record) {
|
||||||
boolean messageRequestAccepted = RecipientUtil.isMessageRequestAccepted(context, record.getThreadId());
|
boolean messageRequestAccepted = RecipientUtil.isMessageRequestAccepted(context, record.getThreadId());
|
||||||
RecipientId threadRecipientId = getRecipientIdForThreadId(record.getThreadId());
|
RecipientId threadRecipientId = getRecipientIdForThreadId(record.getThreadId());
|
||||||
RecipientId individualRecipient = record.getIndividualRecipient().getId();
|
RecipientId individualRecipient = record.getIndividualRecipient().getId();
|
||||||
|
|
|
@ -199,18 +199,31 @@ public abstract class MessageRecord extends DisplayRecord {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSelfCreatedGroup() {
|
public boolean isSelfCreatedGroup() {
|
||||||
if (!isGroupUpdate() || !isGroupV2()) return false;
|
DecryptedGroupV2Context decryptedGroupV2Context = getDecryptedGroupV2Context();
|
||||||
|
|
||||||
try {
|
if (decryptedGroupV2Context == null) {
|
||||||
byte[] decoded = Base64.decode(getBody());
|
|
||||||
DecryptedGroupChange change = DecryptedGroupV2Context.parseFrom(decoded)
|
|
||||||
.getChange();
|
|
||||||
|
|
||||||
return selfCreatedGroup(change);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.w(TAG, "GV2 Message update detail could not be read", e);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
DecryptedGroupChange change = decryptedGroupV2Context.getChange();
|
||||||
|
|
||||||
|
return selfCreatedGroup(change);
|
||||||
|
}
|
||||||
|
|
||||||
|
private @Nullable DecryptedGroupV2Context getDecryptedGroupV2Context() {
|
||||||
|
if (!isGroupUpdate() || !isGroupV2()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
DecryptedGroupV2Context decryptedGroupV2Context;
|
||||||
|
try {
|
||||||
|
byte[] decoded = Base64.decode(getBody());
|
||||||
|
decryptedGroupV2Context = DecryptedGroupV2Context.parseFrom(decoded);
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.w(TAG, "GV2 Message update detail could not be read", e);
|
||||||
|
decryptedGroupV2Context = null;
|
||||||
|
}
|
||||||
|
return decryptedGroupV2Context;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean selfCreatedGroup(@NonNull DecryptedGroupChange change) {
|
private static boolean selfCreatedGroup(@NonNull DecryptedGroupChange change) {
|
||||||
|
@ -240,9 +253,12 @@ public abstract class MessageRecord extends DisplayRecord {
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable InviteAddState getGv2AddInviteState() {
|
public @Nullable InviteAddState getGv2AddInviteState() {
|
||||||
try {
|
DecryptedGroupV2Context decryptedGroupV2Context = getDecryptedGroupV2Context();
|
||||||
byte[] decoded = Base64.decode(getBody());
|
|
||||||
DecryptedGroupV2Context decryptedGroupV2Context = DecryptedGroupV2Context.parseFrom(decoded);
|
if (decryptedGroupV2Context == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
DecryptedGroup groupState = decryptedGroupV2Context.getGroupState();
|
DecryptedGroup groupState = decryptedGroupV2Context.getGroupState();
|
||||||
boolean invited = DecryptedGroupUtil.findPendingByUuid(groupState.getPendingMembersList(), Recipient.self().requireUuid()).isPresent();
|
boolean invited = DecryptedGroupUtil.findPendingByUuid(groupState.getPendingMembersList(), Recipient.self().requireUuid()).isPresent();
|
||||||
|
|
||||||
|
@ -256,10 +272,6 @@ public abstract class MessageRecord extends DisplayRecord {
|
||||||
|
|
||||||
Log.w(TAG, "GV2 Message editor could not be determined");
|
Log.w(TAG, "GV2 Message editor could not be determined");
|
||||||
return null;
|
return null;
|
||||||
} catch (IOException e) {
|
|
||||||
Log.w(TAG, "GV2 Message update detail could not be read", e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NonNull String getCallDateString(@NonNull Context context) {
|
private @NonNull String getCallDateString(@NonNull Context context) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue