Fix potential NPE during group send.
This commit is contained in:
parent
c725a2fabb
commit
db4634a0dd
2 changed files with 9 additions and 2 deletions
|
@ -2114,10 +2114,12 @@ public class SignalServiceMessageSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < RETRY_COUNT; i++) {
|
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);
|
Set<SignalProtocolAddress> sharedWith = aciStore.getSenderKeySharedWith(distributionId);
|
||||||
List<SignalServiceAddress> needsSenderKey = targetInfo.destinations.stream()
|
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()))
|
.map(a -> ServiceId.parseOrThrow(a.getName()))
|
||||||
.distinct()
|
.distinct()
|
||||||
.map(SignalServiceAddress::new)
|
.map(SignalServiceAddress::new)
|
||||||
|
|
|
@ -56,6 +56,11 @@ public class SignalSealedSessionCipher {
|
||||||
{
|
{
|
||||||
try (SignalSessionLock.Lock unused = lock.acquire()) {
|
try (SignalSessionLock.Lock unused = lock.acquire()) {
|
||||||
List<SessionRecord> recipientSessions = recipients.stream().map(sessionMap::get).collect(Collectors.toList());
|
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);
|
return cipher.multiRecipientEncrypt(recipients, recipientSessions, content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue