24494 Commits

Author SHA1 Message Date
Łukasz Langa
f3994ade31
Python 3.9.21 2024-12-03 18:50:13 +01:00
Łukasz Langa
a897b4a46e
[3.9] gh-122792: Make IPv4-mapped IPv6 address properties consistent with IPv4 (GH-122793) (GH-123819) (GH-127571)
Make IPv4-mapped IPv6 address properties consistent with IPv4.
(cherry picked from commit 76a1c5d18312712baed4699fe7333abb050ec9b7)
(cherry picked from commit b58da409aac90123c1159916908a4c49144925ee)

Co-authored-by: Seth Michael Larson <seth@python.org>
2024-12-03 18:42:19 +01:00
Miss Islington (bot)
08830c7042
[3.9] gh-95588: Drop the safety claim from ast.literal_eval docs. (GH-95919) (GH-126729)
It was never really safe and this claim conflicts directly with the big warning in the docs about it being able to crash the interpreter.
(cherry picked from commit 8baef8ae367041a5cfefb40b19c7b87e9bcb56a2)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-12-03 17:08:42 +01:00
Seth Michael Larson
6b8f44236a
[3.9] gh-126623: Update libexpat to 2.6.4, make future updates easier (GH-126792) (GH-126800)
(cherry picked from commit 3c9996909402fadc98e6ca2a64e75a71a7427352)
2024-12-02 16:07:24 +01:00
Victor Stinner
ddca295319
[3.9] gh-103848: Adds checks to ensure that bracketed hosts found by urlsplit are of IPv6 or IPvFuture format (#103849) (#126976)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
(cherry picked from commit 29f348e232e82938ba2165843c448c2b291504c5)

Co-authored-by: JohnJamesUtley <81572567+JohnJamesUtley@users.noreply.github.com>
2024-12-02 13:36:46 +01:00
Miss Islington (bot)
011fb84db5
[3.9] gh-109396: Fix test_socket.test_hmac_sha1() in FIPS mode (GH-109423) (GH-125107)
Use a longer key: FIPS mode requires at least of at least 112 bits.
The previous key was only 32 bits.

(cherry picked from commit e091b9f20fa8e409003af79f3c468b8225e6dcd3)
(cherry picked from commit f7bfac4b3dd30920f97a542fd78c355ce62aa267)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-11-04 16:17:48 +01:00
Victor Stinner
633555735a
[3.9] gh-124651: Quote template strings in venv activation scripts (GH-124712) (GH-126185) (GH-126269) (GH-126301)
(cherry picked from commit ae961ae94bf19c8f8c7fbea3d1c25cc55ce8ae97)
2024-11-04 16:16:35 +01:00
Petr Viktorin
bbe8756043
[3.9] gh-125041: gh-90781: test_zlib: For s390x HW acceleration, skip checking the compressed bytes (GH-125042) (#125587)
This backports two commits:

- GH-31096 skipped the tests unconditionally
- GH-125042 skips only the possibly-failing assertion

(cherry picked from commit d522856)
2024-10-28 13:50:42 +01:00
Miss Islington (bot)
681e0fa658
[3.9] gh-100454: Fix running SSL tests with OpenSSL 3.1+ (GH-100456) (GH-125186)
This fixes Ubuntu pipeline with OpenSSL 3.1+

(cherry picked from commit 333c7dccd87c637d0b15cf81f9bbec28e39664fd)

Co-authored-by: Dimitri John Ledkov <19779+xnox@users.noreply.github.com>
Co-authored-by: Illia Volochii <illia.volochii@gmail.com>
2024-10-09 15:41:22 +02:00
Łukasz Langa
8c3f7946ec
Python 3.9.20 2024-09-06 21:03:56 +02:00
Petr Viktorin
ee953f2b8f
[3.9] [CVE-2023-27043] gh-102988: Reject malformed addresses in email.parseaddr() (GH-111116) (#123769)
Detect email address parsing errors and return empty tuple to
indicate the parsing error (old API). Add an optional 'strict'
parameter to getaddresses() and parseaddr() functions. Patch by
Thomas Dwyer.

(cherry picked from commit 4a153a1d3b18803a684cd1bcc2cdf3ede3dbae19)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-Authored-By: Thomas Dwyer <github@tomd.tel>
2024-09-06 13:13:54 +02:00
Seth Michael Larson
c57c4a9667
[3.9] gh-123678: Upgrade libexpat 2.6.3 (#123711)
(cherry picked from commit fdc04ad75a410ed3af99edfc32c38b5fc3375f52)
2024-09-05 14:27:48 +02:00
Serhiy Storchaka
a5798d0cc7
[3.9] gh-67693: Fix urlunparse() and urlunsplit() for URIs with path starting with multiple slashes and no authority (GH-113563) (#119027)
(cherry picked from commit e237b25a4fa5626fcd1b1848aa03f725f892e40e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-09-05 14:05:43 +02:00
Łukasz Langa
0152431f17
[3.9] gh-112275: Fix HEAD_LOCK deadlock in child process after fork (GH-112336) (#123688)
HEAD_LOCK is called from _PyEval_ReInitThreads->_PyThreadState_DeleteExcept before _PyRuntimeState_ReInitThreads reinit runtime->interpreters.mutex which might be locked before fork.

(cherry picked from commit 522799a05e3e820339718151ac055af6d864d463)

Co-authored-by: ChuBoning <102216855+ChuBoning@users.noreply.github.com>
2024-09-04 22:41:03 +02:00
Miss Islington (bot)
9290419492
[3.9] gh-119690: Fixes buffer type confusion in _winapi.CreateFile and _winapi.CreateNamedPipe audit events (GH-119735) (#123679)
(cherry picked from commit 2e861ac1cd4359463f6a13efd3d3578fce71e5ab)

Co-authored-by: Steve Dower <steve.dower@python.org>
2024-09-04 18:22:50 +02:00
Miss Islington (bot)
d662e2db26
[3.9] gh-123067: Fix quadratic complexity in parsing "-quoted cookie values with backslashes (GH-123075) (#123107)
This fixes CVE-2024-7592.
(cherry picked from commit 44e458357fca05ca0ae2658d62c8c595b048b5ef)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-09-04 17:49:40 +02:00
Jason R. Coombs
962055268e
[3.9] gh-123270: Replaced SanitizedNames with a more surgical fix. (GH-123354) (#123432)
Applies changes from zipp 3.20.1 and jaraco/zippGH-124
(cherry picked from commit 2231286d78d328c2f575e0b05b16fe447d1656d6)
(cherry picked from commit 17b77bb41409259bad1cd6c74761c18b6ab1e860)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2024-09-04 17:46:48 +02:00
Seth Michael Larson
b4225ca915
[3.9] gh-121285: Remove backtracking when parsing tarfile headers (GH-121286) (#123641)
* Remove backtracking when parsing tarfile headers
* Rewrite PAX header parsing to be stricter
* Optimize parsing of GNU extended sparse headers v0.0

(cherry picked from commit 34ddb64d088dd7ccc321f6103d23153256caa5d4)

Co-authored-by: Seth Michael Larson <seth@python.org>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-09-04 17:46:01 +02:00
Łukasz Langa
f7be505d13
[3.9] gh-121650: Encode newlines in headers, and verify headers are sound (GH-122233) (#122610)
Per RFC 2047:

> [...] these encoding schemes allow the
> encoding of arbitrary octet values, mail readers that implement this
> decoding should also ensure that display of the decoded data on the
> recipient's terminal will not cause unwanted side-effects

It seems that the "quoted-word" scheme is a valid way to include
a newline character in a header value, just like we already allow
undecodable bytes or control characters.
They do need to be properly quoted when serialized to text, though.

This should fail for custom fold() implementations that aren't careful
about newlines.

(cherry picked from commit 097633981879b3c9de9a1dd120d3aa585ecc2384)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Bas Bloemsaat <bas@bloemsaat.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-09-04 17:39:02 +02:00
Miss Islington (bot)
06fa244666
[3.9] gh-122133: Authenticate socket connection for socket.socketpair() fallback (GH-122134) (#122428)
Authenticate socket connection for `socket.socketpair()` fallback when the platform does not have a native `socketpair` C API.  We authenticate in-process using `getsocketname` and `getpeername` (thanks to Nathaniel J Smith for that suggestion).

(cherry picked from commit 78df1043dbdce5c989600616f9f87b4ee72944e5)

Co-authored-by: Seth Michael Larson <seth@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-07-30 14:44:26 +02:00
Łukasz Langa
9e9c71d09e
[3.9] gh-121957: Emit audit events for python -i and python -m asyncio (GH-122120) 2024-07-22 13:49:47 +02:00
Ned Deily
54b5e9e9a8
[3.9] gh-112769: test_zlib: test_zlib: Fix comparison of ZLIB_RUNTIME_VERSION with non-int suffix (GH-112771) (GH-119566)
zlib-ng defines the version as "1.3.0.zlib-ng".

(cherry picked from commit d384813)

Co-authored-by: Miro Hrončok miro@hroncok.cz
2024-05-30 18:36:05 +02:00
Steve Dower
5130731c9e
[3.9] gh-118486: Support mkdir(mode=0o700) on Windows (GH-118488) (GH-118741)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-24 19:27:01 +02:00
Seth Michael Larson
b228655c22
[3.9] gh-114572: Fix locking in cert_store_stats and get_ca_certs (#118109) 2024-05-10 13:46:12 +02:00
Petr Viktorin
22adf29da8
[3.9] gh-113171: gh-65056: Fix "private" (non-global) IP address ranges (GH-113179) (GH-113186) (GH-118177) (GH-118472)
The _private_networks variables, used by various is_private
implementations, were missing some ranges and at the same time had
overly strict ranges (where there are more specific ranges considered
globally reachable by the IANA registries).

This patch updates the ranges with what was missing or otherwise
incorrect.

100.64.0.0/10 is left alone, for now, as it's been made special in [1].

The _address_exclude_many() call returns 8 networks for IPv4, 121
networks for IPv6.

[1] https://github.com/python/cpython/issues/61602

In 3.10 and below, is_private checks whether the network and broadcast
address are both private.
In later versions (where the test wss backported from), it checks
whether they both are in the same private network.

For 0.0.0.0/0, both 0.0.0.0 and 255.225.255.255 are private,
but one is in 0.0.0.0/8 ("This network") and the other in
255.255.255.255/32 ("Limited broadcast").

---------

Co-authored-by: Jakub Stasiak <jakub@stasiak.at>
2024-05-07 11:57:58 +02:00
Seth Michael Larson
7db40cd3a9
[3.9] gh-116741: Upgrade libexpat to 2.6.2 (GH-117296) (GH-118187)
(cherry picked from commit c9829eec0883a8991ea4d319d965e123a3cf6c20)
2024-05-07 10:50:48 +02:00
jkriegshauser
40d77b9367
[3.9] gh-116773: Fix overlapped memory corruption crash (GH-116774) (GH-117080)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-03-27 16:24:46 +01:00
Miss Islington (bot)
f7c7e72a1c
[3.9] gh-117187: Fix XML tests for vanilla Expat <2.6.0 (GH-117203) (GH-117247)
This fixes XML unittest fallout from the https://github.com/python/cpython/issues/115398 security fix.  When configured using `--with-system-expat` on systems with older pre 2.6.0 versions of libexpat, our unittests were failing.

(cherry picked from commit 9f74e86c78853c101a23e938f8e32ea838d8f62e)

Co-authored-by: Sebastian Pipping <sebastian@pipping.org>
2024-03-27 14:45:22 +01:00
Łukasz Langa
882f62bd93
Python 3.9.19 2024-03-19 16:48:02 +01:00
Miss Islington (bot)
fc2c98f92f
[3.9] gh-115197: Stop resolving host in urllib.request proxy bypass (GH-115210) (GH-116068)
Use of a proxy is intended to defer DNS for the hosts to the proxy itself, rather than a potential for information leak of the host doing DNS resolution itself for any reason.  Proxy bypass lists are strictly name based.  Most implementations of proxy support agree.
(cherry picked from commit c43b26d02eaa103756c250e8d36829d388c5f3be)

Co-authored-by: Weii Wang <weii.wang@canonical.com>
2024-03-19 11:53:42 +01:00
Sebastian Pipping
200762426b
[3.9] gh-115398: Expose Expat >=2.6.0 reparse deferral API (CVE-2023-52425) (GH-115623) (GH-116272)
Allow controlling Expat >=2.6.0 reparse deferral (CVE-2023-52425) by adding five new methods:

- `xml.etree.ElementTree.XMLParser.flush`
- `xml.etree.ElementTree.XMLPullParser.flush`
- `xml.parsers.expat.xmlparser.GetReparseDeferralEnabled`
- `xml.parsers.expat.xmlparser.SetReparseDeferralEnabled`
- `xml.sax.expatreader.ExpatParser.flush`

Based on the "flush" idea from https://github.com/python/cpython/pull/115138#issuecomment-1932444270 .

Includes code suggested-by: Snild Dolkow <snild@sony.com>
and by core dev Serhiy Storchaka.

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-03-07 00:03:30 +01:00
Miss Islington (bot)
468ba95c79
[3.9] gh-107077: Raise SSLCertVerificationError even if the error is set via SSL_ERROR_SYSCALL (GH-107586) (#107590)
(cherry picked from commit 77e09192b5f1caf14cd5f92ccb53a4592e83e8bc)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: T. Wouters <thomas@python.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-02-21 17:02:34 +01:00
Seth Michael Larson
4b68e5d7ab
[3.9] Upgrade bundled libexpat to 2.6.0 (GH-115399) (GH-115474)
Manual backport due to code differences.
(cherry picked from commit e071b0d558b2f5cddd5a9fc6afadb4ba109ec77e)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-02-21 13:48:13 +01:00
Miss Islington (bot)
0397866920
[3.9] gh-115399: Document CVE-2023-52425 under "XML vulnerabilities" (GH-115400) (GH-115763)
Doc/library/xml.rst: Document CVE-2023-52425 under "XML vulnerabilities"
(cherry picked from commit fbd40ce46e7335a5dbaf48a3aa841be22d7302ba)

Co-authored-by: Sebastian Pipping <sebastian@pipping.org>
2024-02-21 12:45:14 +01:00
Seth Michael Larson
dafb4f0c6b
[3.9] Fix tests for XMLPullParser with Expat 2.6.0 (GH-115133) (GH-115535)
Feeding the parser by too small chunks defers parsing to prevent
CVE-2023-52425. Future versions of Expat may be more reactive.
(cherry picked from commit 4a08e7b3431cd32a0daf22a33421cd3035343dc4)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-02-21 12:22:55 +01:00
Miss Islington (bot)
fa1f564118
[3.9] Add missing sections to blurbs (GH-114553) (GH-115339)
(cherry picked from commit dc8893af7df706138161d82ce7d1d2f9132d14f9)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-02-13 13:56:31 +01:00
Łukasz Langa
24c6514765
[3.9] gh-111239: Update Windows build to use zlib 1.3.1 (GH-114877) (GH-115087)
(cherry picked from commit 618d7256e78da8200f6e2c6235094a1ef885dca4)

Co-authored-by: Zachary Ware <zach@python.org>
2024-02-06 16:08:31 +01:00
Serhiy Storchaka
8fc8c45b67
[3.9] gh-113659: Skip hidden .pth files (GH-113660) (GH-114146)
(cherry picked from commit 74208ed0c440244fb809d8acc97cb9ef51e888e3)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-01-17 15:28:17 +01:00
Miss Islington (bot)
a2c59992e9
[3.9] gh-109858: Protect zipfile from "quoted-overlap" zipbomb (GH-110016) (GH-113915)
Raise BadZipFile when try to read an entry that overlaps with other entry or
central directory.
(cherry picked from commit 66363b9a7b9fe7c99eba3a185b74c5fdbf842eba)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-01-17 14:48:06 +01:00
Serhiy Storchaka
d54e22a669
[3.9] gh-91133: tempfile.TemporaryDirectory: fix symlink bug in cleanup (GH-99930) (GH-112842)
(cherry picked from commit 81c16cd94ec38d61aa478b9a452436dc3b1b524d)

Co-authored-by: Søren Løvborg <sorenl@unity3d.com>
2024-01-17 14:47:47 +01:00
Miss Islington (bot)
a6f73f6114
[3.9] bpo-37013: Fix the error handling in socket.if_indextoname() (GH-13503) (GH-112600)
* Fix a crash when pass UINT_MAX.
* Fix an integer overflow on 64-bit non-Windows platforms.
(cherry picked from commit 0daf555c6fb3feba77989382135a58215e1d70a5)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2024-01-17 14:47:26 +01:00
Zachary Ware
75da5067cf
[3.9] gh-109991: Update Windows build to use OpenSSL 1.1.1w (GH-111265)
(cherry picked from commit dcb16c98be61630369227f0d893f8d9262d25cac)

Co-authored-by: Steve Dower <steve.dower@python.org>
2024-01-17 14:47:09 +01:00
Ned Deily
f4118e9995
[3.9] gh-109991: Update GitHub CI workflows to use OpenSSL 3.0.11 and multissltests to use 1.1.1w and 3.0.11. (GH-110008)
(cherry picked from commit c88037d137a98d7c399c7bd74d5117b5bcae1543)
2024-01-17 14:46:46 +01:00
Łukasz Langa
08b640e157
[3.9] gh-101180: Fix a bug where iso2022_jp_3 and iso2022_jp_2004 codecs read out of bounds (gh-111695) (gh-111780)
(cherry picked from commit c8faa3568afd255708096f6aa8df0afa80cf7697)

Co-authored-by: Masayuki Moriyama <masayuki.moriyama@miraclelinux.com>
2023-11-06 18:44:50 +01:00
Łukasz Langa
376d66eb50
Python 3.9.18 2023-08-24 19:59:28 +02:00
Ned Deily
d31ae21e5d
[3.9] gh-107565: Update multissltests and GitHub CI workflows to use OpenSSL 1.1.1v, 3.0.10, and 3.1.2. (#108123)
[3.9] gh-107565: Update multissltests and GitHub CI workflows to use  OpenSSL 1.1.1v, 3.0.10, and 3.1.2.

(cherry picked from commit 441797d4ffb12acda257370b9e5e19ed8d6e8a71)
2023-08-22 20:28:57 +02:00
Petr Viktorin
42deeab5b2
[3.9] gh-107845: Fix symlink handling for tarfile.data_filter (GH-107846) (#108274)
(cherry picked from commit acbd3f9c5c5f23e95267714e41236140d84fe962)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Lumír 'Frenzy' Balhar <frenzy.madness@gmail.com>
2023-08-22 20:28:10 +02:00
Serhiy Storchaka
4a79328195
[3.9] gh-99612: Fix PyUnicode_DecodeUTF8Stateful() for ASCII-only data (GH-99613) (GH-107224) (#107231)
Previously *consumed was not set in this case.
(cherry picked from commit f08e52ccb027f6f703302b8c1a82db9fd3934270).
(cherry picked from commit b8b3e6afc0a48c3cbb7c36d2f73e332edcd6058c)
2023-08-22 20:25:15 +02:00
Łukasz Langa
264b1dacc6
[3.9] gh-108310: Fix CVE-2023-40217: Check for & avoid the ssl pre-close flaw (#108320)
gh-108310: Fix CVE-2023-40217: Check for & avoid the ssl pre-close flaw

Instances of `ssl.SSLSocket` were vulnerable to a bypass of the TLS handshake
and included protections (like certificate verification) and treating sent
unencrypted data as if it were post-handshake TLS encrypted data.

The vulnerability is caused when a socket is connected, data is sent by the
malicious peer and stored in a buffer, and then the malicious peer closes the
socket within a small timing window before the other peers’ TLS handshake can
begin. After this sequence of events the closed socket will not immediately
attempt a TLS handshake due to not being connected but will also allow the
buffered data to be read as if a successful TLS handshake had occurred.

Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
2023-08-22 19:57:10 +02:00
Łukasz Langa
0d3cd4eb66
Python 3.9.17 2023-06-06 11:32:53 +02:00