summary refs log tree commit diff
path: root/synapse/handlers/message.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-05-01 18:14:18 +0100
committerRichard van der Hoff <richard@matrix.org>2018-05-01 18:14:18 +0100
commitd5eee5d601cb291bcd6eb409f818c0e27a1658b0 (patch)
tree8c71771ba723609335feb16568fe0b540a33d451 /synapse/handlers/message.py
parentMiscellaneous fixes to python_dependencies (diff)
parentApply some limits to depth to counter abuse (diff)
downloadsynapse-d5eee5d601cb291bcd6eb409f818c0e27a1658b0.tar.xz
Merge commit '33f469b' into release-v0.28.1
Diffstat (limited to 'synapse/handlers/message.py')
-rw-r--r--synapse/handlers/message.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index 21628a8540..53beb2b9ab 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -16,7 +16,7 @@
 from twisted.internet import defer, reactor
 from twisted.python.failure import Failure
 
-from synapse.api.constants import EventTypes, Membership
+from synapse.api.constants import EventTypes, Membership, MAX_DEPTH
 from synapse.api.errors import AuthError, Codes, SynapseError
 from synapse.crypto.event_signing import add_hashes_and_signatures
 from synapse.events.utils import serialize_event
@@ -624,6 +624,10 @@ class EventCreationHandler(object):
 
         if prev_events_and_hashes:
             depth = max([d for _, _, d in prev_events_and_hashes]) + 1
+            # we cap depth of generated events, to ensure that they are not
+            # rejected by other servers (and so that they can be persisted in
+            # the db)
+            depth = min(depth, MAX_DEPTH)
         else:
             depth = 1