From 524bda5b39ac31edf0d0f8d6cf50a0bfec8daae2 Mon Sep 17 00:00:00 2001 From: dece Date: Fri, 5 Mar 2021 19:28:17 +0100 Subject: [PATCH] protocol: limit meta line length in request --- bebop/protocol.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bebop/protocol.py b/bebop/protocol.py index fe42f01..bcab2ef 100644 --- a/bebop/protocol.py +++ b/bebop/protocol.py @@ -175,6 +175,7 @@ class Response: content: bytes = b"" HEADER_RE = re.compile(r"(\d{2}) (.*)") + MAX_META_LEN = 1024 @property def generic_code(self): @@ -192,6 +193,8 @@ class Response: if not match: return None code, meta = match.groups() + if len(meta) > Response.MAX_META_LEN: + return None response = Response(StatusCode(int(code)), meta=meta) if response.generic_code == StatusCode.SUCCESS: content_offset = response_header_len + len(LINE_TERM)