Commit graph

109617 commits

Author SHA1 Message Date
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 4a153a1d3b)

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 fdc04ad75a)
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 e237b25a4f)

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 522799a05e)

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 2e861ac1cd)

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 44e458357f)

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 2231286d78)
(cherry picked from commit 17b77bb414)

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 34ddb64d08)

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 0976339818)

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)
3f5d9d12c7
[3.9] gh-122133: Rework pure Python socketpair tests to avoid use of importlib.reload. (GH-122493) (GH-122508)
(cherry picked from commit f071f01b7b)

Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-08-02 15:10:52 +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 78df1043db)

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 c9829eec08)
2024-05-07 10:50:48 +02:00
Miss Islington (bot)
22ae383462
[3.9] gh-114539: Clarify implicit launching of shells by subprocess (GH-117996) (GH-118005)
(cherry picked from commit a4b44d39cd)

Co-authored-by: Steve Dower <steve.dower@python.org>
2024-05-07 10:48:03 +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 9f74e86c78)

Co-authored-by: Sebastian Pipping <sebastian@pipping.org>
2024-03-27 14:45:22 +01:00
Łukasz Langa
a04a0f6585
Post 3.9.19 2024-03-19 17:18:11 +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 c43b26d02e)

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 77e09192b5)

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 e071b0d558)

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 fbd40ce46e)

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 4a08e7b343)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-02-21 12:22:55 +01:00
Miss Islington (bot)
c23f74903f
[3.9] gh-97032: avoid test_squeezer crash on macOS buildbots (GH-115508) (#115655)
(cherry picked from commit 17a6533dbf)

Co-authored-by: Ned Deily <nad@python.org>
2024-02-21 12:17:44 +01:00
Hugo van Kemenade
3fcea416f8
[3.9] gh-115349: Pin theme to fix code snippets (GH-115351)
Pin theme to fix code snippets
2024-02-13 13:56:59 +01:00
Miss Islington (bot)
fa1f564118
[3.9] Add missing sections to blurbs (GH-114553) (GH-115339)
(cherry picked from commit dc8893af7d)

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 618d7256e7)

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 74208ed0c4)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-01-17 15:28:17 +01:00
Miss Islington (bot)
dd068eaf48
[3.9] gh-107888: Fix test_mmap.test_access_parameter() on macOS 14 (GH-109928) (GH-114184)
(cherry picked from commit 9dbfe2dc8e)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-01-17 15:10:35 +01:00
Adam Turner
2613df8ee2
[3.9] gh-114021: Pin various sphinxcontrib extensions to older versions (GH-114022) (GH-114039)
(cherry picked from commit 94b1d1fa38)

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
2024-01-17 14:48:31 +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 66363b9a7b)

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 81c16cd94e)

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 0daf555c6f)

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 dcb16c98be)

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 c88037d137)
2024-01-17 14:46:46 +01:00
Maciej Olko
f86e20e4a8
[3.9] Fix documentation build by pinning Alabaster version to 0.7.13 (#113815)
Alabaster is Sphinx's dependency. Alabaster 0.7.14 released on 2024-01-08 dropped support for Sphinx 3.3 and earlier.

https://alabaster.readthedocs.io/en/latest/changelog.html
2024-01-10 10:35:38 +01:00
Seth Michael Larson
300d3155af
[3.9] gh-112160: Add 'regen-configure' make target (#112164)
Add 'regen-configure' make target
2023-12-07 00:26:24 +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 c8faa3568a)

Co-authored-by: Masayuki Moriyama <masayuki.moriyama@miraclelinux.com>
2023-11-06 18:44:50 +01:00
Miss Islington (bot)
43a6e4fa49
[3.9] gh-109002: Ensure only one wheel for each vendored package (GH-109003) (#109008)
Output with one wheel:
```
❯ GITHUB_ACTIONS=true ./Tools/build/verify_ensurepip_wheels.py
Verifying checksum for /Volumes/RAMDisk/cpython/Lib/ensurepip/_bundled/pip-23.2.1-py3-none-any.whl.
Expected digest: 7ccf472345f20d35bdc9d1841ff5f313260c2c33fe417f48c30ac46cccabf5be
Actual digest:   7ccf472345f20d35bdc9d1841ff5f313260c2c33fe417f48c30ac46cccabf5be
::notice file=/Volumes/RAMDisk/cpython/Lib/ensurepip/_bundled/pip-23.2.1-py3-none-any.whl::Successfully verified the checksum of the pip wheel.
```

Output with two wheels:
```
❯ GITHUB_ACTIONS=true ./Tools/build/verify_ensurepip_wheels.py
::error file=/Volumes/RAMDisk/cpython/Lib/ensurepip/_bundled/pip-22.0.4-py3-none-any.whl::Found more than one wheel for package pip.

::error file=/Volumes/RAMDisk/cpython/Lib/ensurepip/_bundled/pip-23.2.1-py3-none-any.whl::Found more than one wheel for package pip.
```

Output without wheels:
```
❯ GITHUB_ACTIONS=true ./Tools/build/verify_ensurepip_wheels.py
::error file=::Could not find a pip wheel on disk.
```
(cherry picked from commit f8a047941f)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-09-06 20:01:05 +02:00
Hugo van Kemenade
13905c93b6
[3.9] CI: Bump GitHub Actions (GH-108879) (#108893)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-09-05 22:39:06 +02:00
Miss Islington (bot)
e4b971c338
[3.9] [3.10] Add a dummy .rtfd.yml file to silence invalid failing webhooks (GH-108908) (#108925)
(cherry picked from commit 5970435b26)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-09-05 17:37:59 +02:00
Łukasz Langa
cf69231a70
Post 3.9.18 2023-08-24 21:18:58 +02:00
Łukasz Langa
376d66eb50
Python 3.9.18 2023-08-24 19:59:28 +02:00
Łukasz Langa
92f9ce726b
Fix invalid string escape 2023-08-24 19:44:27 +02:00
Łukasz Langa
d2cd0a3acb
[3.9] gh-108342: Make ssl TestPreHandshakeClose more reliable (GH-108370) (#108407)
* In preauth tests of test_ssl, explicitly break reference cycles
  invoving SingleConnectionTestServerThread to make sure that the
  thread is deleted. Otherwise, the test marks the environment as
  altered because the threading module sees a "dangling thread"
  (SingleConnectionTestServerThread). This test leak was introduced
  by the test added for the fix of issue gh-108310.
* Use support.SHORT_TIMEOUT instead of hardcoded 1.0 or 2.0 seconds
  timeout.
* SingleConnectionTestServerThread.run() catchs TimeoutError
* Fix a race condition (missing synchronization) in
  test_preauth_data_to_tls_client(): the server now waits until the
  client connect() completed in call_after_accept().
* test_https_client_non_tls_response_ignored() calls server.join()
  explicitly.
* Replace "localhost" with server.listener.getsockname()[0].
(cherry picked from commit 592bacb6fc)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-08-24 12:09:11 +02:00