Commit graph

27299 commits

Author SHA1 Message Date
Miss Islington (bot)
2c6ca1a9ad
[3.11] gh-128840: Fix parsing long IPv6 addresses with embedded IPv4 address (GH-134836) (GH-135091)
(cherry picked from commit d83576bf48)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-03 16:24:20 +02:00
Miss Islington (bot)
9df171dbba
[3.11] gh-123409: fix IPv6Address.reverse_pointer for IPv4-mapped addresses (GH-123419) (GH-135087)
Fix functionality that was broken with better textual representation for IPv4-mapped addresses (gh-87799)
(cherry picked from commit 77a2fb4bf1)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-06-03 16:03:49 +02:00
Miss Islington (bot)
da3755557a
[3.11] gh-128840: Limit the number of parts in IPv6 address parsing (GH-128841) (GH-134613)
Limit length of IP address string to 39

(cherry picked from commit 47f1161d3a)

Co-authored-by: Seth Michael Larson <seth@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-06-03 15:55:00 +02:00
Miss Islington (bot)
f38f9cf7f8
[3.11] gh-87799: Improve the textual representation of IPv4-mapped IPv6 addresses (GH-29345) (GH-135080)
Represent IPv4-mapped IPv6 address as xxxd.d.d.d,
where the 'x's are the hexadecimal values
of the six high-order 16-bit pieces of the address,
and the 'd's are the decimal values
of the four low-order 8-bit pieces of the address
(standard IPv4 representation).

(cherry picked from commit f22bf8e3cf)

Co-authored-by: opavliuk <40970635+opavlyuk@users.noreply.github.com>
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2025-06-03 15:43:36 +02:00
Miss Islington (bot)
f8b4421bc5
[3.11] gh-134062: Fix hash collisions in IPv4Network and IPv6Network (GH-134063) (GH-134479)
(cherry picked from commit f3fc0c16e0)

Co-authored-by: Mike Salvatore <mike.s.salvatore@gmail.com>
2025-06-02 17:53:12 +02:00
Serhiy Storchaka
73b3040f59
[3.11] gh-133767: Fix use-after-free in the unicode-escape decoder with an error handler (GH-129648) (GH-133944) (GH-134341)
If the error handler is used, a new bytes object is created to set as
the object attribute of UnicodeDecodeError, and that bytes object then
replaces the original data. A pointer to the decoded data will became invalid
after destroying that temporary bytes object. So we need other way to return
the first invalid escape from _PyUnicode_DecodeUnicodeEscapeInternal().

_PyBytes_DecodeEscape() does not have such issue, because it does not
use the error handlers registry, but it should be changed for compatibility
with _PyUnicode_DecodeUnicodeEscapeInternal().
(cherry picked from commit 9f69a58623)
(cherry picked from commit 6279eb8c07)
(cherry picked from commit a75953b347)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-02 17:52:52 +02:00
Pablo Galindo
da1f6c61dd
Python 3.11.12 2025-04-08 15:15:29 +01:00
Seth Michael Larson
553d7069e2
[3.11] gh-131809: Upgrade vendored expat to 2.7.1 (GH-132192) (#132240)
(cherry picked from commit c0de650024)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-04-08 11:36:51 +02:00
Seth Michael Larson
ba49eab9aa
[3.11] gh-131261: Update libexpat to 2.7.0 (CVE-2024-8176) (GH-131272) (GH-131362)
(cherry picked from commit bb0268f60d)
(cherry picked from commit 6af54d298d)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-04-03 18:32:11 +02:00
Miss Islington (bot)
0a66052d8d
[3.11] gh-121284: Fix email address header folding with parsed encoded-word (GH-122754) (GH-131405)
Email generators using email.policy.default may convert an RFC 2047
encoded-word to unencoded form during header refolding. In a structured
header, this could allow 'specials' chars outside a quoted-string,
leading to invalid address headers and enabling spoofing. This change
ensures a parsed encoded-word that contains specials is kept as an
encoded-word while the header is refolded.

[Better fix from @bitdancer.]

(cherry picked from commit 295b53df2a)

Co-authored-by: Mike Edmunds <medmunds@gmail.com>
Co-authored-by: R David Murray <rdmurray@bitdance.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-04-03 18:27:02 +02:00
Victor Stinner
4588712773
[3.11] gh-127257: ssl: Raise OSError for ERR_LIB_SYS (GH-127361) (GH-127905) (GH-131970)
gh-127257: ssl: Raise OSError for ERR_LIB_SYS (GH-127361)

From the ERR_raise manpage:

    ERR_LIB_SYS

        This "library code" indicates that a system error is
        being reported.  In this case, the reason code given
        to `ERR_raise()` and `ERR_raise_data()` *must* be
        `errno(3)`.

This PR only handles ERR_LIB_SYS for the high-lever error types
SSL_ERROR_SYSCALL and SSL_ERROR_SSL, i.e., not the ones where
OpenSSL indicates it has some more information about the issue.

(cherry picked from commit f4b31edf2d)
(cherry picked from commit 7f707fa6c6)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-04-03 18:25:51 +02:00
Diego Russo
6b37486184
[3.11] gh-106883 Fix deadlock in threaded application (#117332)
When using threaded applications, there is a high risk of a deadlock in
the interpreter. It's a lock ordering deadlock with HEAD_LOCK(&_PyRuntime); and the GIL.

By disabling the GC during the _PyThread_CurrentFrames() and
_PyThread_CurrentExceptions() calls fixes the issue.
2025-03-11 15:31:03 +00:00
Miss Islington (bot)
3abcace681
[3.11] gh-119511: Fix a potential denial of service in imaplib (GH-119514) (#129357)
The IMAP4 client could consume an arbitrary amount of memory when trying
to connect to a malicious server, because it read a "literal" data with a
single read(size) call, and BufferedReader.read() allocates the bytes
object of the specified size before reading. Now the IMAP4 client reads data
by chunks, therefore the amount of used memory is limited by the
amount of the data actually been sent by the server.
(cherry picked from commit 735f25c5e3)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-02-19 14:16:30 +01:00
Miss Islington (bot)
526617ed68
[3.11] gh-105704: Disallow square brackets ([ and ]) in domain names for parsed URLs (GH-129418) (#129528)
Co-authored-by: Seth Michael Larson <seth@python.org>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-02-19 14:13:52 +01:00
Miss Islington (bot)
7cff053efe
[3.11] gh-80222: Fix email address header folding with long quoted-string (GH-122753) (#129009)
Email generators using email.policy.default could incorrectly omit the
quote ('"') characters from a quoted-string during header refolding,
leading to invalid address headers and enabling header spoofing. This
change restores the quote characters on a bare-quoted-string as the
header is refolded, and escapes backslash and quote chars in the string.
(cherry picked from commit 5aaf416858)

Co-authored-by: Mike Edmunds <medmunds@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-02-19 14:12:34 +01:00
Miss Islington (bot)
a83a7cfff4
[3.11] gh-128874: Fix the documentation for blurb 2.0 (GH-128875) (#128879)
gh-128874: Fix the documentation for blurb 2.0 (GH-128875)
(cherry picked from commit 40a4d88a14)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-01-21 19:26:25 +00:00
Petr Viktorin
f0895aa9c1
[3.11] gh-121277: Allow .. versionadded:: next in docs (GH-121278) (#124718) (#127827)
* [3.11] gh-121277: Allow `.. versionadded:: next` in docs (GH-121278) (#124718)

Make `versionchanged:: next`` expand to current (unreleased) version.

When a new CPython release is cut, the release manager will replace
all such occurences of "next" with the just-released version.
(See the issue for release-tools and devguide PRs.)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
(cherry picked from commit 7d24ea9db3)

gh-121277: Raise nice error on `next` as second argument to deprecated-removed (GH-124623)

(cherry-picked from e349f73a5a)

* Import VersionChange

sphinx.domains.changeset.VersionChange exists at least since Sphinx 2.1,
according to: https://www.sphinx-doc.org/en/master/extdev/deprecated.html

* Get config from env

* Use version, not arguments directly
2024-12-11 14:58:46 +00:00
Pablo Galindo
d03b868578 Python 3.11.11 2024-12-03 12:20:40 -05:00
Miss Islington (bot)
66a01b068b
[3.11] gh-122792: Make IPv4-mapped IPv6 address properties consistent with IPv4 (GH-122793) (GH-123818)
Make IPv4-mapped IPv6 address properties consistent with IPv4.
(cherry picked from commit 76a1c5d183)

Co-authored-by: Seth Michael Larson <seth@python.org>

---------

Co-authored-by: Seth Michael Larson <seth@python.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-12-03 17:57:10 +01:00
Seth Michael Larson
2e161e2499
[3.11] gh-126623: Update libexpat to 2.6.4, make future updates easier (GH-126792) (GH-126798)
Update libexpat to 2.6.4, make future updates easier.
(cherry picked from commit 3c99969094)
2024-12-03 17:42:23 +01:00
Victor Stinner
ae961ae94b
[3.11] gh-124651: Quote template strings in venv activation scripts (GH-124712) (GH-126185) (#126269) 2024-11-01 13:11:47 +00:00
Zachary Ware
e84015f846
[3.11] gh-123418: Update CI to use fresh OpenSSL releases (GH-123675) (#123699)
* [3.11] gh-123418: Update CI to use fresh OpenSSL releases (GH-123675)

Also adds openssl/openssl GitHub URL template for newer OpenSSL downloads
(cherry picked from commit 56b00f4705)

Co-authored-by: Zachary Ware <zach@python.org>

* Adjust build_ubuntu_ssltests job to use cache for the correct OS version
2024-10-22 15:48:51 +00:00
Petr Viktorin
8630002c5c
[3.11] gh-125041: test_zlib: For s390x HW acceleration, only skip checking the compressed bytes (GH-125042) (#125577)
gh-125041: test_zlib: For s390x HW acceleration, only skip checking the compressed bytes (#125042)

(cherry picked from commit cc5a225cdc)
2024-10-22 12:11:14 +01:00
Pablo Galindo
0c47759eee Python 3.11.10 2024-09-07 02:03:31 +01:00
Petr Viktorin
bc4a703a93
[3.11] [CVE-2023-27043] gh-102988: Reject malformed addresses in email.parseaddr() (GH-111116) (#123767)
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 12:46:23 +02:00
Zachary Ware
5752116ed7
[3.11] gh-123418: Update OpenSSL to 3.0.15 on Windows (GH-123673) (#123692)
(cherry picked from commit d2eafe2f48)
2024-09-05 14:28:35 +02:00
Seth Michael Larson
b582d5234f
[3.11] gh-123678: Upgrade libexpat 2.6.3 (#123709)
(cherry picked from commit e6fe0ac014)
2024-09-05 14:27:22 +02:00
ChuBoning
522799a05e
[3.11]GH-112275: Fix HEAD_LOCK deadlock in child process after fork (#112336)
HEAD_LOCK is called from _PyEval_ReInitThreads->_PyThreadState_DeleteExcept before _PyRuntimeState_ReInitThreads reinit runtime->interpreters.mutex which might be locked before fork.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-09-04 19:14:59 +02:00
Steve Dower
697beec04d
[3.11] gh-119690: Fixes buffer type confusion in _winapi.CreateNamedPipe audit event (#119734)
gh-119690: Fixes buffer type confusion in _winapi.CreateNamedPipe audit event
2024-09-04 18:02:48 +02:00
Jason R. Coombs
fc0b8259e6
[3.11] gh-123270: Replaced SanitizedNames with a more surgical fix. (GH-123354) (#123425)
Applies changes from zipp 3.20.1 and jaraco/zippGH-124
(cherry picked from commit 2231286d78)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>

* Restore the slash-prefixed paths in the malformed_paths test.
2024-09-04 17:52:54 +02:00
Miss Islington (bot)
d4ac921a4b
[3.11] gh-123067: Fix quadratic complexity in parsing "-quoted cookie values with backslashes (GH-123075) (#123105)
This fixes CVE-2024-7592.
(cherry picked from commit 44e458357f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-09-04 17:50:00 +02:00
Serhiy Storchaka
d0e8c100e4
[3.11] gh-67693: Fix urlunparse() and urlunsplit() for URIs with path starting with multiple slashes and no authority (GH-113563) (#119025)
(cherry picked from commit e237b25a4f)
2024-09-04 17:42:58 +02:00
Łukasz Langa
f7c0f09e69
[3.11] gh-121650: Encode newlines in headers, and verify headers are sound (GH-122233) (#122608)
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.

Verify that email headers are well-formed.

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:37:28 +02:00
Seth Michael Larson
d449caf8a1
[3.11] gh-121285: Remove backtracking when parsing tarfile headers (GH-121286) (#123639)
* 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: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-09-03 15:07:13 +00:00
Jason R. Coombs
795f2597a4
[3.11] gh-122905: Sanitize names in zipfile.Path. (GH-122906) (#122925)
* gh-122905: Sanitize names in zipfile.Path. (#122906)

Ported from zipp 3.19.1; ref jaraco/zipp#119.

(cherry picked from commit 9cd0326310)

* [3.11] gh-122905: Sanitize names in zipfile.Path. (GH-122906)

Ported from zipp 3.19.1; ref jaraco/zippGH-119.
(cherry picked from commit 9cd0326310)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2024-08-20 00:28:20 +01:00
Inada Naoki
8a978a75c2
[3.11] gh-119506: fix _io.TextIOWrapper.write() write during flush (#119507) (#120314)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
fix _io.TextIOWrapper.write() write during flush (#119507)
2024-08-09 17:04:36 +00:00
Miss Islington (bot)
5f90abaa78
[3.11] gh-122133: Authenticate socket connection for socket.socketpair() fallback (GH-122134) (#122426)
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:43:45 +02:00
Łukasz Langa
d542a9be51
[3.11] gh-121957: Emit audit events for python -i and python -m asyncio (GH-122118) 2024-07-22 13:44:55 +02:00
Steve Dower
35c799d791
[3.11] gh-118486: Support mkdir(mode=0o700) on Windows (GH-118488) (GH-118739) 2024-05-24 02:13:18 +02:00
Serhiy Storchaka
4762b36540
[3.11] gh-118643: Fix AttributeError in the email module (GH-119099) (#119393)
Fix regression introduced in gh-100884: AttributeError when re-fold a long
address list.

Also fix more cases of incorrect encoding of the address separator in the
address list missed in gh-100884.
(cherry picked from commit 858b9e85fc)
2024-05-23 13:09:03 +01:00
Petr Viktorin
ba431579ef
[3.11] gh-113171: gh-65056: Fix "private" (non-global) IP address ranges (GH-113179) (GH-113186) (GH-118177) (#118227) 2024-04-25 13:45:48 +01:00
Seth Michael Larson
8133285c13
[3.11] gh-116741: Upgrade libexpat to 2.6.2 (GH-117296) (#118185)
Upgrade libexpat to 2.6.2
(cherry picked from commit c9829eec08)
2024-04-23 12:28:50 -07:00
Grigoriev Semyon
3bc0d2b851
[3.11] gh-109120: Fix syntax error in handlinh of incorrect star expressions… (#117464)
gh-109120: Fix syntax error in handlinh of incorrect star expressions (#117444)

(cherry picked from commit c97d3af239)
2024-04-03 11:37:39 +01:00
Pablo Galindo
de54cf5be3 Python 3.11.9 2024-04-02 09:25:04 +01:00
Miss Islington (bot)
01ab43c08a
[3.11] gh-117110: Fix subclasses of typing.Any with custom constructors (GH-117111) (#117358)
gh-117110: Fix subclasses of typing.Any with custom constructors (GH-117111)
(cherry picked from commit 8eec7ed714)

Co-authored-by: 傅立业(Chris Fu) <17433201@qq.com>
2024-03-29 00:38:13 +00:00
Miss Islington (bot)
65a0923c70
[3.11] gh-117310: Remove extra DECREF on "no ciphers" error path in _ssl._SSLContext constructor (GH-117309) (GH-117318)
gh-117310: Remove extra DECREF on "no ciphers" error path in `_ssl._SSLContext` constructor (GH-117309)

Remove extra self DECREF on ssl "no ciphers" error path.

This doesn't come up in practice because nobody links against a broken
OpenSSL library that provides nothing.
(cherry picked from commit 8cb7d7ff86)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-03-28 10:05:19 -07:00
Miss Islington (bot)
c703b7b54f
[3.11] gh-117178: Recover lazy loading of self-referential modules (GH-117179) (#117320)
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
2024-03-28 11:17:10 +00:00
Miss Islington (bot)
2d932361a8
[3.11] gh-66543: Fix mimetype.guess_type() (GH-117217) (GH-117257)
Fix parsing of the following corner cases:

* URLs with only a host name
* URLs containing a fragment
* URLs containing a query
* filenames with only a UNC sharepoint on Windows

(cherry picked from commit 9654daf793)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
2024-03-26 11:46:28 +00:00
Miss Islington (bot)
04b26eeb14
[3.11] [3.12] gh-83434: Sync libregrtest and test_regrtest with the main branch (GH-117250) (#117251)
[3.12] gh-83434: Sync libregrtest and test_regrtest with the main branch (GH-117250)

* gh-115122: Add --bisect option to regrtest (GH-115123)

* test.bisect_cmd now exit with code 0 on success, and code 1 on
  failure. Before, it was the opposite.
* test.bisect_cmd now runs the test worker process with
  -X faulthandler.
* regrtest RunTests: Add create_python_cmd() and bisect_cmd()
  methods.

(cherry picked from commit 1e5719a663)

* gh-115720: Show number of leaks in huntrleaks progress reports (GH-115726)

Instead of showing a dot for each iteration, show:
- '.' for zero (on negative) leaks
- number of leaks for 1-9
- 'X' if there are more leaks

This allows more rapid iteration: when bisecting, I don't need
to wait for the final report to see if the test still leaks.

Also, show the full result if there are any non-zero entries.
This shows negative entries, for the unfortunate cases where
a reference is created and cleaned up in different runs.

Test *failure* is still determined by the existing heuristic.

(cherry picked from commit af5f9d682c)

* gh-83434: Disable XML in regrtest when -R option is used (GH-117232)

(cherry picked from commit d52bdfb19f)

---------

(cherry picked from commit 477ef9015c)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-03-26 08:18:10 +00:00
Miss Islington (bot)
2f8d3a17d9
[3.11] gh-117187: Fix XML tests for vanilla Expat <2.6.0 (GH-117203) (GH-117245)
gh-117187: Fix XML tests for vanilla Expat <2.6.0 (GH-117203)

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.

* sax|etree: Simplify Expat version guard where simplifiable

Idea by Matěj Cepl

* sax|etree: Fix reparse deferral tests for vanilla Expat <2.6.0

This *does not fix* the case of distros with an older version of libexpat with the 2.6.0 feature backported as a security fix.  (Ubuntu is a known example of this with its libexpat1 2.5.0-2ubunutu0.1 package)
(cherry picked from commit 9f74e86c78)

Co-authored-by: Sebastian Pipping <sebastian@pipping.org>
2024-03-26 02:08:28 +00:00