]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Handle invalid content-length
authordaftshady <daftonshady@gmail.com>
Sun, 15 May 2016 14:01:17 +0000 (23:01 +0900)
committerdaftshady <daftonshady@gmail.com>
Sun, 15 May 2016 14:01:17 +0000 (23:01 +0900)
tornado/http1connection.py

index 8194f91436beca1853a7ac435ec936f8760736c2..43034c6b503d45404c9ef10d7917fcb77d106c45 100644 (file)
@@ -540,7 +540,13 @@ class HTTP1Connection(httputil.HTTPConnection):
                         "Multiple unequal Content-Lengths: %r" %
                         headers["Content-Length"])
                 headers["Content-Length"] = pieces[0]
-            content_length = int(headers["Content-Length"])
+
+            try:
+                content_length = int(headers["Content-Length"])
+            except ValueError:
+                # Handles non-integer Content-Length value.
+                raise httputil.HTTPInputError(
+                    "Only integer Content-Length is allowed: %s" % headers["Content-Length"])
 
             if content_length > self._max_body_size:
                 raise httputil.HTTPInputError("Content-Length too long")