mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-25 19:12:19 +00:00
Enforce max envelope size in more places.
This commit is contained in:

committed by
Cody Henthorne

parent
0068d62122
commit
f4c1e34402
@@ -107,7 +107,8 @@ public final class FeatureFlags {
|
|||||||
private static final Set<String> HOT_SWAPPABLE = Sets.newHashSet(
|
private static final Set<String> HOT_SWAPPABLE = Sets.newHashSet(
|
||||||
GROUPS_V2_JOIN_VERSION,
|
GROUPS_V2_JOIN_VERSION,
|
||||||
VERIFY_V2,
|
VERIFY_V2,
|
||||||
CLIENT_EXPIRATION
|
CLIENT_EXPIRATION,
|
||||||
|
MAX_ENVELOPE_SIZE
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -701,13 +701,7 @@ public class SignalServiceMessageSender {
|
|||||||
|
|
||||||
builder.setTimestamp(message.getTimestamp());
|
builder.setTimestamp(message.getTimestamp());
|
||||||
|
|
||||||
byte[] content = container.setDataMessage(builder).build().toByteArray();
|
return enforceMaxContentSize(container.setDataMessage(builder).build().toByteArray());
|
||||||
|
|
||||||
if (maxEnvelopeSize > 0 && content.length > maxEnvelopeSize) {
|
|
||||||
throw new ContentTooLargeException(content.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
return content;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] createCallContent(SignalServiceCallMessage callMessage) {
|
private byte[] createCallContent(SignalServiceCallMessage callMessage) {
|
||||||
@@ -1261,6 +1255,8 @@ public class SignalServiceMessageSender {
|
|||||||
CancelationSignal cancelationSignal)
|
CancelationSignal cancelationSignal)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
enforceMaxContentSize(content);
|
||||||
|
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
List<Future<SendMessageResult>> futureResults = new LinkedList<>();
|
List<Future<SendMessageResult>> futureResults = new LinkedList<>();
|
||||||
Iterator<SignalServiceAddress> recipientIterator = recipients.iterator();
|
Iterator<SignalServiceAddress> recipientIterator = recipients.iterator();
|
||||||
@@ -1325,6 +1321,8 @@ public class SignalServiceMessageSender {
|
|||||||
CancelationSignal cancelationSignal)
|
CancelationSignal cancelationSignal)
|
||||||
throws UntrustedIdentityException, IOException
|
throws UntrustedIdentityException, IOException
|
||||||
{
|
{
|
||||||
|
enforceMaxContentSize(content);
|
||||||
|
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
for (int i = 0; i < RETRY_COUNT; i++) {
|
for (int i = 0; i < RETRY_COUNT; i++) {
|
||||||
@@ -1591,6 +1589,13 @@ public class SignalServiceMessageSender {
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private byte[] enforceMaxContentSize(byte[] content) {
|
||||||
|
if (maxEnvelopeSize > 0 && content.length > maxEnvelopeSize) {
|
||||||
|
throw new ContentTooLargeException(content.length);
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
public static interface EventListener {
|
public static interface EventListener {
|
||||||
public void onSecurityEvent(SignalServiceAddress address);
|
public void onSecurityEvent(SignalServiceAddress address);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user