diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2014-08-05 04:15:57 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2014-08-05 04:15:57 (GMT) |
commit | b7414e0fdb35d21612895cbb41f993808f755c40 (patch) | |
tree | 3d7b6ca0aeeec525bcedd5440a218582c2d832df /Lib/httplib.py | |
parent | c468abafc7a8690be365d1eb192c4551b03c2856 (diff) | |
download | cpython-b7414e0fdb35d21612895cbb41f993808f755c40.zip cpython-b7414e0fdb35d21612895cbb41f993808f755c40.tar.gz cpython-b7414e0fdb35d21612895cbb41f993808f755c40.tar.bz2 |
Issue #16037: HTTPMessage.readheaders() raises an HTTPException when more
than 100 headers are read.
Patch by Jyrki Pulliainen and Daniel Eriksson.
Diffstat (limited to 'Lib/httplib.py')
-rw-r--r-- | Lib/httplib.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py index 5368cd9..b2f6e5c 100644 --- a/Lib/httplib.py +++ b/Lib/httplib.py @@ -215,6 +215,10 @@ MAXAMOUNT = 1048576 # maximal line length when calling readline(). _MAXLINE = 65536 +# maximum amount of headers accepted +_MAXHEADERS = 100 + + class HTTPMessage(mimetools.Message): def addheader(self, key, value): @@ -271,6 +275,8 @@ class HTTPMessage(mimetools.Message): elif self.seekable: tell = self.fp.tell while True: + if len(hlist) > _MAXHEADERS: + raise HTTPException("got more than %d headers" % _MAXHEADERS) if tell: try: startofline = tell() |