Properly handle too-large messages
1. Take note of any large messages. 2. If they are way too large, we just drop them on the floor. // FREEBIE
This commit is contained in:
parent
0113bb2c11
commit
91ad2ec32b
|
@ -125,7 +125,7 @@ EXTERNAL SOURCES:
|
|||
:branch: signal-master
|
||||
:git: https://github.com/WhisperSystems/JSQMessagesViewController.git
|
||||
SignalServiceKit:
|
||||
:path: .
|
||||
:path: "."
|
||||
SocketRocket:
|
||||
:git: https://github.com/facebook/SocketRocket.git
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ EXTERNAL SOURCES:
|
|||
AxolotlKit:
|
||||
:git: https://github.com/WhisperSystems/SignalProtocolKit.git
|
||||
SignalServiceKit:
|
||||
:path: ../../../SignalServiceKit.podspec
|
||||
:path: "../../../SignalServiceKit.podspec"
|
||||
SocketRocket:
|
||||
:git: https://github.com/facebook/SocketRocket.git
|
||||
|
||||
|
|
|
@ -333,6 +333,20 @@ NSString *const OWSMessageProcessingJobFinderExtensionGroup = @"OWSMessageProces
|
|||
|
||||
- (void)handleReceivedEnvelope:(OWSSignalServiceProtosEnvelope *)envelope
|
||||
{
|
||||
// Drop any too-large messages on the floor. Well behaving clients should never send them.
|
||||
NSUInteger kMaxEnvelopeByteCount = 250 * 1024;
|
||||
if (envelope.serializedSize > kMaxEnvelopeByteCount) {
|
||||
OWSProdError(@"message_receiver_error_oversize_message");
|
||||
return;
|
||||
}
|
||||
|
||||
// Take note of any messages larger than we expect, but still process them.
|
||||
// This likely indicates a misbehaving sending client.
|
||||
NSUInteger kLargeEnvelopeWarningByteCount = 25 * 1024;
|
||||
if (envelope.serializedSize > kLargeEnvelopeWarningByteCount) {
|
||||
OWSProdError(@"message_receiver_error_large_message");
|
||||
}
|
||||
|
||||
[self.processingQueue enqueueEnvelopeForProcessing:envelope];
|
||||
[self.processingQueue drainQueue];
|
||||
}
|
||||
|
|
|
@ -392,13 +392,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
return;
|
||||
}
|
||||
|
||||
NSUInteger kMaxEncryptedDataLength = 250 * 1024;
|
||||
if (encryptedData.length > kMaxEncryptedDataLength) {
|
||||
OWSProdError(@"message_manager_error_oversize_message");
|
||||
completion(nil);
|
||||
return;
|
||||
}
|
||||
|
||||
NSData *plaintextData;
|
||||
|
||||
@try {
|
||||
|
|
Loading…
Reference in New Issue