diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-28 16:28:49 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-28 16:28:49 +0100 |
| commit | 595bfd57dc8179f9588e2a8d1e0efd1194e6246c (patch) | |
| tree | 3f1b89d8e23934b9539aa67f1b8d98e1fe54844b /tests | |
| parent | 1c356825832e549570c690a170a84270022578e5 (diff) | |
Ensure one byte in the reply buffer for the terminator
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/integration/test_announce.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/integration/test_announce.py b/tests/integration/test_announce.py index 0eee0fe..2d21417 100644 --- a/tests/integration/test_announce.py +++ b/tests/integration/test_announce.py | |||
| @@ -124,6 +124,18 @@ class AnnounceRejects(TrackerTestCase): | |||
| 124 | def test_a_port_that_is_not_a_number_is_rejected(self): | 124 | def test_a_port_that_is_not_a_number_is_rejected(self): |
| 125 | self.assert_rejected("info_hash=" + "a" * 20 + "&peer_id=" + "b" * 20 + "&port=abc&left=0") | 125 | self.assert_rejected("info_hash=" + "a" * 20 + "&peer_id=" + "b" * 20 + "&port=abc&left=0") |
| 126 | 126 | ||
| 127 | def test_an_ip_that_fills_the_reply_buffer_is_refused(self): | ||
| 128 | """The value is decoded into the reply buffer and then terminated, so | ||
| 129 | the longest one that fits has to leave room for the terminator. 8096 | ||
| 130 | bytes is what lies between where it is decoded and the buffer's end.""" | ||
| 131 | connection = self.tracker.connect() | ||
| 132 | try: | ||
| 133 | connection.sock.sendall(b"GET /a?ip=" + b"1" * 8096 + b"\n\n") | ||
| 134 | status, _, _ = connection.reply() | ||
| 135 | self.assertTrue(status.startswith(b"HTTP/1.0 400"), status) | ||
| 136 | finally: | ||
| 137 | connection.close() | ||
| 138 | |||
| 127 | def test_two_info_hashes_are_rejected(self): | 139 | def test_two_info_hashes_are_rejected(self): |
| 128 | self.assert_rejected("info_hash=" + "a" * 20 + "&info_hash=" + "c" * 20 + "&peer_id=" + "b" * 20 + "&port=6881&left=0") | 140 | self.assert_rejected("info_hash=" + "a" * 20 + "&info_hash=" + "c" * 20 + "&peer_id=" + "b" * 20 + "&port=6881&left=0") |
| 129 | 141 | ||
