commit 676c60b98528669c8a6befcf62f6fd76f46bfbd8 parent a252aed301aa182a19571465c725a832530f95c7 Author: Natalie Pendragon <natpen@natpen.net> Date: Wed, 3 Jun 2020 13:24:24 -0400 Only read 1027 bytes in header Diffstat:
M | gusmobile/client.py | | | 10 | +++++++--- |
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/gusmobile/client.py b/gusmobile/client.py @@ -68,9 +68,13 @@ def fetch(raw_url): return else: address, f = _send_request(url) - # Read response header - header = f.readline() - header = header.decode("UTF-8").strip() + # Read response header + header = f.readline(1027) + header = header.decode("UTF-8") + if not header or header[-1] != '\n': + _debug("ERROR: Received invalid header from server!") + return + header = header.strip() _debug("Response header: %s." % header) # Catch network errors which may happen on initial connection