Annotation of pkgsrc/lang/python27/patches/patch-Lib_test_test__httplib.py, revision 1.4
1.4 ! gutterid 1: $NetBSD: patch-Lib_test_test__httplib.py,v 1.3 2020/09/27 14:57:22 leot Exp $
1.2 mgorny 2:
1.3 leot 3: bpo-39603 (CVE-2020-26116): header injection via HTTP method
1.2 mgorny 4:
1.4 ! gutterid 5: Taken from:
1.2 mgorny 6: https://gitweb.gentoo.org/fork/cpython.git/commit/?h=gentoo-2.7-vanilla&id=138e2caeb4827ccfd1eaff2cf63afb79dfeeb3c4
1.1 mgorny 7:
1.4 ! gutterid 8: Fix CVE-2021-3737: http client infinite line reading (DoS) after a HTTP 100 Continue
! 9: Via Fedora:
! 10: https://src.fedoraproject.org/rpms/python2.7/blob/rawhide/f/00368-CVE-2021-3737.patch
! 11:
1.1 mgorny 12: --- Lib/test/test_httplib.py.orig 2020-04-19 21:13:39.000000000 +0000
13: +++ Lib/test/test_httplib.py
14: @@ -384,6 +384,26 @@ class HeaderTests(TestCase):
15: with self.assertRaisesRegexp(ValueError, 'Invalid header'):
16: conn.putheader(name, value)
17:
18: + def test_invalid_method_names(self):
19: + methods = (
20: + 'GET\r',
21: + 'POST\n',
22: + 'PUT\n\r',
23: + 'POST\nValue',
24: + 'POST\nHOST:abc',
25: + 'GET\nrHost:abc\n',
26: + 'POST\rRemainder:\r',
27: + 'GET\rHOST:\n',
28: + '\nPUT'
29: + )
30: +
31: + for method in methods:
32: + with self.assertRaisesRegexp(
33: + ValueError, "method can't contain control characters"):
34: + conn = httplib.HTTPConnection('example.com')
35: + conn.sock = FakeSocket(None)
36: + conn.request(method=method, url="/")
37: +
38:
39: class BasicTest(TestCase):
40: def test_status_lines(self):
1.4 ! gutterid 41: @@ -655,6 +675,14 @@ class BasicTest(TestCase):
! 42: resp = httplib.HTTPResponse(FakeSocket(body))
! 43: self.assertRaises(httplib.LineTooLong, resp.begin)
! 44:
! 45: + def test_overflowing_header_limit_after_100(self):
! 46: + body = (
! 47: + 'HTTP/1.1 100 OK\r\n'
! 48: + 'r\n' * 32768
! 49: + )
! 50: + resp = httplib.HTTPResponse(FakeSocket(body))
! 51: + self.assertRaises(httplib.HTTPException, resp.begin)
! 52: +
! 53: def test_overflowing_chunked_line(self):
! 54: body = (
! 55: 'HTTP/1.1 200 OK\r\n'
CVSweb <webmaster@jp.NetBSD.org>