Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 88abf67

Browse files
author
Anselm Kruis
committed
Merge tag v3.6.12 into branch 3.6-slp.
2 parents d7b0850 + c0a9afe commit 88abf67

File tree

13 files changed

+141
-16
lines changed

13 files changed

+141
-16
lines changed

Include/patchlevel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
/*--start constants--*/
1919
#define PY_MAJOR_VERSION 3
2020
#define PY_MINOR_VERSION 6
21-
#define PY_MICRO_VERSION 11
21+
#define PY_MICRO_VERSION 12
2222
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL
2323
#define PY_RELEASE_SERIAL 0
2424

2525
/* Version as a string */
26-
#define PY_VERSION "3.6.11+"
26+
#define PY_VERSION "3.6.12"
2727
/*--end constants--*/
2828

2929
/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.

Lib/http/client.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@
151151
# _is_allowed_url_pchars_re = re.compile(r"^[/!$&'()*+,;=:@%a-zA-Z0-9._~-]+$")
152152
# We are more lenient for assumed real world compatibility purposes.
153153

154+
# These characters are not allowed within HTTP method names
155+
# to prevent http header injection.
156+
_contains_disallowed_method_pchar_re = re.compile('[\x00-\x1f]')
157+
154158
# We always set the Content-Length header for these methods because some
155159
# servers will otherwise respond with a 411
156160
_METHODS_EXPECTING_BODY = {'PATCH', 'POST', 'PUT'}
@@ -1119,6 +1123,8 @@ def putrequest(self, method, url, skip_host=False,
11191123
else:
11201124
raise CannotSendRequest(self.__state)
11211125

1126+
self._validate_method(method)
1127+
11221128
# Save the method for use later in the response phase
11231129
self._method = method
11241130

@@ -1209,6 +1215,15 @@ def _encode_request(self, request):
12091215
# ASCII also helps prevent CVE-2019-9740.
12101216
return request.encode('ascii')
12111217

1218+
def _validate_method(self, method):
1219+
"""Validate a method name for putrequest."""
1220+
# prevent http header injection
1221+
match = _contains_disallowed_method_pchar_re.search(method)
1222+
if match:
1223+
raise ValueError(
1224+
f"method can't contain control characters. {method!r} "
1225+
f"(found at least {match.group()!r})")
1226+
12121227
def _validate_path(self, url):
12131228
"""Validate a url for putrequest."""
12141229
# Prevent CVE-2019-9740.

Lib/pydoc_data/topics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Autogenerated by Sphinx on Wed Jun 17 06:55:37 2020
2+
# Autogenerated by Sphinx on Sat Aug 15 02:33:47 2020
33
topics = {'assert': 'The "assert" statement\n'
44
'**********************\n'
55
'\n'

Lib/tarfile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,8 @@ def _proc_pax(self, tarfile):
12311231

12321232
length, keyword = match.groups()
12331233
length = int(length)
1234+
if length == 0:
1235+
raise InvalidHeaderError("invalid header")
12341236
value = buf[match.end(2) + 1:match.start(1) + length - 1]
12351237

12361238
# Normally, we could just use "utf-8" as the encoding and "strict"

Lib/test/pickletester.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,24 @@ def test_compat_unpickle(self):
10001000
self.assertIs(type(unpickled), collections.UserDict)
10011001
self.assertEqual(unpickled, collections.UserDict({1: 2}))
10021002

1003+
def test_bad_reduce(self):
1004+
self.assertEqual(self.loads(b'cbuiltins\nint\n)R.'), 0)
1005+
self.check_unpickling_error(TypeError, b'N)R.')
1006+
self.check_unpickling_error(TypeError, b'cbuiltins\nint\nNR.')
1007+
1008+
def test_bad_newobj(self):
1009+
error = (pickle.UnpicklingError, TypeError)
1010+
self.assertEqual(self.loads(b'cbuiltins\nint\n)\x81.'), 0)
1011+
self.check_unpickling_error(error, b'cbuiltins\nlen\n)\x81.')
1012+
self.check_unpickling_error(error, b'cbuiltins\nint\nN\x81.')
1013+
1014+
def test_bad_newobj_ex(self):
1015+
error = (pickle.UnpicklingError, TypeError)
1016+
self.assertEqual(self.loads(b'cbuiltins\nint\n)}\x92.'), 0)
1017+
self.check_unpickling_error(error, b'cbuiltins\nlen\n)}\x92.')
1018+
self.check_unpickling_error(error, b'cbuiltins\nint\nN}\x92.')
1019+
self.check_unpickling_error(error, b'cbuiltins\nint\n)N\x92.')
1020+
10031021
def test_bad_stack(self):
10041022
badpickles = [
10051023
b'.', # STOP

Lib/test/recursion.tar

516 Bytes
Binary file not shown.

Lib/test/test_httplib.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,28 @@ def test_headers_debuglevel(self):
359359
self.assertEqual(lines[2], "header: Second: val")
360360

361361

362+
class HttpMethodTests(TestCase):
363+
def test_invalid_method_names(self):
364+
methods = (
365+
'GET\r',
366+
'POST\n',
367+
'PUT\n\r',
368+
'POST\nValue',
369+
'POST\nHOST:abc',
370+
'GET\nrHost:abc\n',
371+
'POST\rRemainder:\r',
372+
'GET\rHOST:\n',
373+
'\nPUT'
374+
)
375+
376+
for method in methods:
377+
with self.assertRaisesRegex(
378+
ValueError, "method can't contain control characters"):
379+
conn = client.HTTPConnection('example.com')
380+
conn.sock = FakeSocket(None)
381+
conn.request(method=method, url="/")
382+
383+
362384
class TransferEncodingTest(TestCase):
363385
expected_body = b"It's just a flesh wound"
364386

Lib/test/test_tarfile.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,13 @@ def test_premature_end_of_archive(self):
395395
with self.assertRaisesRegex(tarfile.ReadError, "unexpected end of data"):
396396
tar.extractfile(t).read()
397397

398+
def test_length_zero_header(self):
399+
# bpo-39017 (CVE-2019-20907): reading a zero-length header should fail
400+
# with an exception
401+
with self.assertRaisesRegex(tarfile.ReadError, "file could not be opened successfully"):
402+
with tarfile.open(support.findfile('recursion.tar')) as tar:
403+
pass
404+
398405
class MiscReadTestBase(CommonReadTest):
399406
def requires_name_attribute(self):
400407
pass

Misc/NEWS.d/3.6.12.rst

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.. bpo: 29778
2+
.. date: 2020-07-03-17-21-37
3+
.. nonce: cR_fGS
4+
.. release date: 2020-08-15
5+
.. section: Security
6+
7+
Ensure :file:`python3.dll` is loaded from correct locations when Python is
8+
embedded (CVE-2020-15523).
9+
10+
..
11+
12+
.. bpo: 41004
13+
.. date: 2020-06-29-16-02-29
14+
.. nonce: ovF0KZ
15+
.. section: Security
16+
17+
CVE-2020-14422: The __hash__() methods of ipaddress.IPv4Interface and
18+
ipaddress.IPv6Interface incorrectly generated constant hash values of 32 and
19+
128 respectively. This resulted in always causing hash collisions. The fix
20+
uses hash() to generate hash values for the tuple of (address, mask length,
21+
network address).
22+
23+
..
24+
25+
.. bpo: 39603
26+
.. date: 2020-02-12-14-17-39
27+
.. nonce: Gt3RSg
28+
.. section: Security
29+
30+
Prevent http header injection by rejecting control characters in
31+
http.client.putrequest(...).
32+
33+
..
34+
35+
.. bpo: 41288
36+
.. date: 2020-07-13-15-06-35
37+
.. nonce: 8mn5P-
38+
.. section: Library
39+
40+
Unpickling invalid NEWOBJ_EX opcode with the C implementation raises now
41+
UnpicklingError instead of crashing.
42+
43+
..
44+
45+
.. bpo: 39017
46+
.. date: 2020-07-12-22-16-58
47+
.. nonce: x3Cg-9
48+
.. section: Library
49+
50+
Avoid infinite loop when reading specially crafted TAR files using the
51+
tarfile module (CVE-2019-20907).

Misc/NEWS.d/next/Security/2020-06-29-16-02-29.bpo-41004.ovF0KZ.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)