Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Limit the maximum number events requested when backfilling events.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Feb 6, 2020
1 parent bce5571 commit 9f16a31
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelog.d/6864.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Limit the number of events that can be requested by the backfill federation API to 100.

4 changes: 4 additions & 0 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1789,6 +1789,9 @@ def on_backfill_request(self, origin, room_id, pdu_list, limit):
if not in_room:
raise AuthError(403, "Host not in room.")

# Synapse asks for 100 events per backfill request. Do not allow more.
limit = min(limit, 100)

events = yield self.store.get_backfill_events(room_id, pdu_list, limit)

events = yield filter_events_for_server(self.storage, origin, events)
Expand Down Expand Up @@ -2169,6 +2172,7 @@ async def on_get_missing_events(
if not in_room:
raise AuthError(403, "Host not in room.")

# Only allow up to 20 events to be retrieved per request.
limit = min(limit, 20)

missing_events = await self.store.get_missing_events(
Expand Down

0 comments on commit 9f16a31

Please sign in to comment.