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

Commit

Permalink
Limit the number of events that can be requested when backfilling eve…
Browse files Browse the repository at this point in the history
…nts (#6864)

Limit the maximum number of events requested when backfilling events.
  • Loading branch information
clokep authored Feb 6, 2020
1 parent b0c8bdd commit 7765bf3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/6864.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
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 @@ -1788,6 +1788,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 @@ -2168,6 +2171,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 7765bf3

Please sign in to comment.