From 4fdfc3a76b4a8e5fbdddf776f6b4dcb4d44b4c09 Mon Sep 17 00:00:00 2001 From: Konstantin Kapustin Date: Mon, 20 Aug 2012 16:02:52 +0400 Subject: [PATCH] Fix LimitRequestLine check. --- gunicorn/http/message.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gunicorn/http/message.py b/gunicorn/http/message.py index d2361ca3..8bc4b4cd 100644 --- a/gunicorn/http/message.py +++ b/gunicorn/http/message.py @@ -164,15 +164,19 @@ class Request(Message): while True: idx = data.find("\r\n") if idx >= 0: + # check if the request line is too large + if idx > self.limit_request_line > 0: + raise LimitRequestLine(idx, self.limit_request_line) break - self.get_data(unreader, buf) - data = buf.getvalue() - # check if the request line is too large + # check if chunk is too large before read next chunk if len(data) - 2 > self.limit_request_line and \ self.limit_request_line> 0 : raise LimitRequestLine(len(data), self.limit_request_line) + self.get_data(unreader, buf) + data = buf.getvalue() + self.parse_request_line(data[:idx]) buf = StringIO() buf.write(data[idx+2:]) # Skip \r\n