Fix potential NPE during group send.

This commit is contained in:
Greyson Parrelli 2024-01-16 09:18:00 -05:00
parent c725a2fabb
commit db4634a0dd
2 changed files with 9 additions and 2 deletions

View file

@ -2114,10 +2114,12 @@ public class SignalServiceMessageSender {
}
for (int i = 0; i < RETRY_COUNT; i++) {
GroupTargetInfo targetInfo = buildGroupTargetInfo(recipients);
GroupTargetInfo targetInfo = buildGroupTargetInfo(recipients);
final GroupTargetInfo targetInfoSnapshot = targetInfo;
Set<SignalProtocolAddress> sharedWith = aciStore.getSenderKeySharedWith(distributionId);
List<SignalServiceAddress> needsSenderKey = targetInfo.destinations.stream()
.filter(a -> !sharedWith.contains(a))
.filter(a -> !sharedWith.contains(a) || targetInfoSnapshot.sessions.get(a) == null)
.map(a -> ServiceId.parseOrThrow(a.getName()))
.distinct()
.map(SignalServiceAddress::new)

View file

@ -56,6 +56,11 @@ public class SignalSealedSessionCipher {
{
try (SignalSessionLock.Lock unused = lock.acquire()) {
List<SessionRecord> recipientSessions = recipients.stream().map(sessionMap::get).collect(Collectors.toList());
if (recipientSessions.contains(null)) {
throw new NoSessionException("No session for some recipients");
}
return cipher.multiRecipientEncrypt(recipients, recipientSessions, content);
}
}