Commit graph

48050 commits

Author SHA1 Message Date
Miss Islington (bot)
2bd9f9b054
[3.10] gh-119461: Fix ThreadedVSOCKSocketStreamTest (GH-129171) (#129440)
* [3.11] gh-119461: Fix ThreadedVSOCKSocketStreamTest (GH-129171)

Fix ThreadedVSOCKSocketStreamTest: if get_cid() returns the host
address or the "any" address, use the local communication address
(loopback): VMADDR_CID_LOCAL.

On Linux 6.9, apparently, the /dev/vsock device is now available but
get_cid() returns VMADDR_CID_ANY (-1).

(cherry picked from commit 45db419c31)

Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit e94dbe4ed8)
(cherry picked from commit c750061047)
(cherry picked from commit cbfe3023e4)

* gh-119461: Restore the testSocket VSOCK skipUnless removed by PR #119465 (#129561)

Restore the skipUnless removed by #119465.

This test can only pass on virtual machines, not actual machines.

actual machines see:

```
    self.cli.connect((cid, VSOCKPORT))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
OSError: [Errno 19] No such device
```

Reproduced on (Linux) Ubuntu 24.04.1 running 6.8.0-52-generic.

---------

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-02-13 01:31:13 +00:00
Pablo Galindo
890778604a Python 3.10.16 2024-12-03 12:27:57 -05:00
Miss Islington (bot)
b58da409aa
[3.10] gh-122792: Make IPv4-mapped IPv6 address properties consistent with IPv4 (GH-122793) (GH-123819)
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: Łukasz Langa <lukasz@langa.pl>
2024-12-03 18:07:43 +01:00
Victor Stinner
634ded4554
[3.10] gh-103848: Adds checks to ensure that bracketed hosts found by urlsplit are of IPv6 or IPvFuture format (#103849) (#126975)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
(cherry picked from commit 29f348e232)

Co-authored-by: JohnJamesUtley <81572567+JohnJamesUtley@users.noreply.github.com>
2024-12-02 13:37:05 +01:00
Petr Viktorin
5f24da9d75
[3.10] gh-113027: Fix test_variable_tzname in test_email (GH-113821) (#126438) 2024-11-05 19:55:43 +00:00
Victor Stinner
9286ab3a10
[3.10] gh-124651: Quote template strings in venv activation scripts (GH-124712) (GH-126185) (GH-126269) (GH-126300)
(cherry picked from commit ae961ae94b)
2024-11-04 16:16:17 +01:00
Petr Viktorin
3c63d80b95
[3.10] gh-125041: gh-90781: test_zlib: For s390x HW acceleration, skip checking the compressed bytes (GH-125042) (#125585)
gh-125041: gh-90781: test_zlib: For s390x HW acceleration, skip checking the compressed bytes (GH-125042)

This backports two commits:

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

(cherry picked from commit cc5a225cdc)
2024-10-22 12:11:21 +01:00
Petr Viktorin
6bbaab801b
[3.10] gh-107902: gh-108948: Don't test setting suid/sgid/sticky on systems that don't support them (GH-108368) (GH-109697) (#125255)
* gh-107902: Don't test setting suid/sgid on systems that don't support them (GH-108368)

* gh-108948: Skip test_tarfile.test_modes() on EFTYPE error (#109697)

On FreeBSD, regular users cannot set the sticky bit. Skip the test if
chmod() fails with EFTYPE error.

---------

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-10-22 12:11:11 +01:00
Miss Islington (bot)
b116237592
[3.10] gh-100005: Skip test_script_as_dev_fd() on FreeBSD (GH-100006) (#125109)
gh-100005: Skip test_script_as_dev_fd() on FreeBSD (GH-100006)

On FreeBSD, skip test_script_as_dev_fd() of test_cmd_line_script if
fdescfs is not mounted (at /dev/fd).
(cherry picked from commit 038b151963)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-10-22 12:11:04 +01:00
Miss Islington (bot)
e44b32f1c9
[3.10] gh-109396: Fix test_socket.test_hmac_sha1() in FIPS mode (GH-109423) (#125106)
[3.11] gh-109396: Fix test_socket.test_hmac_sha1() in FIPS mode (GH-109423) (GH-109427)

gh-109396: Fix test_socket.test_hmac_sha1() in FIPS mode (GH-109423)

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

(cherry picked from commit f7bfac4b3d)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-10-22 12:10:53 +01:00
Pablo Galindo
ffee63f344 Python 3.10.15 2024-09-07 01:20:06 +01:00
Petr Viktorin
2a9273a0e4
[3.10] [CVE-2023-27043] gh-102988: Reject malformed addresses in email.parseaddr() (GH-111116) (#123768)
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:14:22 +02:00
Jason R. Coombs
4633177a08
[3.10] gh-123693: Use platform-agnostic semantics when processing zipfile.Path.name. (#123694)
Applies changes from zipp 3.20.1 and jaraco/zippGH-124
(cherry picked from commit 2231286d78)
(cherry picked from commit 17b77bb)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2024-09-05 11:15:03 +02:00
Jason R. Coombs
0aa1ee22ab
[3.10] gh-123270: Replaced SanitizedNames with a more surgical fix. (GH-123354) (#123426)
Applies changes from zipp 3.20.1 and jaraco/zippGH-124
(cherry picked from commit 2231286d78)
(cherry picked from commit 17b77bb)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2024-09-04 22:41:39 +02:00
Miss Islington (bot)
b2f11ca766
[3.10] gh-123067: Fix quadratic complexity in parsing "-quoted cookie values with backslashes (GH-123075) (#123106)
This fixes CVE-2024-7592.
(cherry picked from commit 44e458357f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-09-04 17:50:36 +02:00
Serhiy Storchaka
2fa5d70684
[3.10] gh-67693: Fix urlunparse() and urlunsplit() for URIs with path starting with multiple slashes and no authority (GH-113563) (#119026)
(cherry picked from commit e237b25a4f)
2024-09-04 17:43:30 +02:00
Łukasz Langa
06f28dc236
[3.10] gh-121650: Encode newlines in headers, and verify headers are sound (GH-122233) (#122609)
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:38:31 +02:00
Seth Michael Larson
743acbe872
[3.10] gh-121285: Remove backtracking when parsing tarfile headers (GH-121286) (#123640)
* 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:53 +00:00
Jason R. Coombs
e0264a6111
[3.10] gh-122905: Sanitize names in zipfile.Path. (GH-122906) (#123160)
[3.10] [3.11] gh-122905: Sanitize names in zipfile.Path. (GH-122906) (GH-122925)

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

Ported from zipp 3.19.1; ref jaraco/zippGH-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)

(cherry picked from commit 795f2597a4)
2024-08-23 00:24:33 +01:00
Miss Islington (bot)
31302f5fc2
[3.10] gh-122133: Rework pure Python socketpair tests to avoid use of importlib.reload. (GH-122493) (GH-122507)
(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:39 +02:00
Miss Islington (bot)
0b65c8bf53
[3.10] gh-122133: Authenticate socket connection for socket.socketpair() fallback (GH-122134) (#122427)
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:16 +02:00
Łukasz Langa
d86ab5dde2
[3.10] gh-121957: Emit audit events for python -i and python -m asyncio (GH-122119) 2024-07-22 13:48:50 +02:00
Ned Deily
48f9d3e3fa
[3.10] gh-112769: test_zlib: test_zlib: Fix comparison of ZLIB_RUNTIME_VERSION with non-int suffix (GH-112771) (#119565)
[3.10] gh-112769: test_zlib: test_zlib: Fix comparison of ZLIB_RUNTIME_VERSION with non-int suffix

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-28 16:57:05 +01:00
Steve Dower
c8f868dc52
[3.10] gh-118486: Support mkdir(mode=0o700) on Windows (GH-118488) (GH-118740)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-24 19:26:44 +02:00
Petr Viktorin
c62c9e518b
[3.10] gh-113171: gh-65056: Fix "private" (non-global) IP address ranges (GH-113179) (GH-113186) (GH-118177) (GH-118229)
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:56:13 +02:00
jkriegshauser
812245ecce
[3.10] gh-116773: Fix overlapped memory corruption crash (GH-116774) (GH-117079)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-03-27 16:24:34 +01:00
Miss Islington (bot)
0a263ccd1f
[3.10] gh-117187: Fix XML tests for vanilla Expat <2.6.0 (GH-117203) (GH-117246)
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.

Co-authored-by: Sebastian Pipping <sebastian@pipping.org>
2024-03-27 14:44:58 +01:00
Łukasz Langa
976ea78599
Python 3.10.14 2024-03-19 22:46:16 +01:00
Miss Islington (bot)
eac14953a0
[3.10] gh-115197: Stop resolving host in urllib.request proxy bypass (GH-115210) (GH-116070)
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:33 +01:00
Sebastian Pipping
516a6d4237
[3.10] gh-115398: Expose Expat >=2.6.0 reparse deferral API (CVE-2023-52425) (GH-115623) (GH-116270)
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:02:55 +01:00
Ned Deily
17a6533dbf
[3.10] gh-97032: avoid test_squeezer crash on macOS buildbots (#115508)
avoid test_squeezer crash on macOS buildbots
2024-02-19 13:43:38 +00:00
Miss Islington (bot)
d9c79e1364
[3.10] gh-115133: Fix tests for XMLPullParser with Expat 2.6.0 (GH-115164) (#115525)
gh-115133: Fix tests for XMLPullParser with Expat 2.6.0 (GH-115164)

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-19 13:38:49 +00:00
Miss Islington (bot)
6091fbda8b
[3.10] gh-105821: Use a raw f-string in test_httpservers.py (GH-105822) (#115519) 2024-02-16 01:06:00 +00:00
Miss Islington (bot)
9afc6d102d
[3.10] gh-113659: Skip hidden .pth files (GH-113660) (GH-114145)
Skip .pth files with names starting with a dot or hidden file attribute.
(cherry picked from commit 74208ed0c4)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-01-18 14:39:30 +01:00
Miss Islington (bot)
1274896727
[3.10] gh-107888: Fix test_mmap.test_access_parameter() on macOS 14 (GH-109928) (GH-114185)
(cherry picked from commit 9dbfe2dc8e)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-01-17 15:02:42 +01:00
Miss Islington (bot)
30fe5d853b
[3.10] gh-109858: Protect zipfile from "quoted-overlap" zipbomb (GH-110016) (GH-113914)
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:50:10 +01:00
Serhiy Storchaka
8eaeefe49d
[3.10] gh-91133: tempfile.TemporaryDirectory: fix symlink bug in cleanup (GH-99930) (GH-112840)
(cherry picked from commit 81c16cd94e)

Co-authored-by: Søren Løvborg <sorenl@unity3d.com>
2024-01-17 14:49:56 +01:00
Miss Islington (bot)
32e7acdc05
[3.10] bpo-37013: Fix the error handling in socket.if_indextoname() (GH-13503) (GH-112599)
* 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:49:40 +01:00
Łukasz Langa
6c2f34fa77
[3.10] gh-101180: Fix a bug where iso2022_jp_3 and iso2022_jp_2004 codecs read out of bounds (gh-111695) (gh-111779)
(cherry picked from commit c8faa3568a)

Co-authored-by: Masayuki Moriyama <masayuki.moriyama@miraclelinux.com>
2023-11-06 15:46:20 +01:00
Pablo Galindo
49965601d6 Python 3.10.13 2023-08-24 13:46:25 +01:00
Łukasz Langa
e96bddf822
[3.10] gh-108342: Make ssl TestPreHandshakeClose more reliable (GH-108370) (#108406)
* 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:00 +02:00
Miss Islington (bot)
893c3b7f5c
[3.10] gh-108342: Break ref cycle in SSLSocket._create() exc (GH-108344) (#108350)
Explicitly break a reference cycle when SSLSocket._create() raises an
exception. Clear the variable storing the exception, since the
exception traceback contains the variables and so creates a reference
cycle.

This test leak was introduced by the test added for the fix of GH-108310.
(cherry picked from commit 64f9935035)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-08-23 12:10:14 +02:00
Miss Islington (bot)
1c937e5887
[3.10] gh-99612: Fix PyUnicode_DecodeUTF8Stateful() for ASCII-only data (GH-99613) (GH-107224) (#107230)
Previously *consumed was not set in this case.

(cherry picked from commit b8b3e6afc0)
(cherry picked from commit f08e52ccb0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-22 20:24:40 +02:00
Łukasz Langa
37d7180cb6
[3.10] gh-108310: Fix CVE-2023-40217: Check for & avoid the ssl pre-close flaw (#108318)
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:53:23 +02:00
Miss Islington (bot)
7d445511f8
[3.10] gh-107845: Fix symlink handling for tarfile.data_filter (GH-107846) (#108210) 2023-08-22 18:02:30 +01:00
Pablo Galindo
b4e48a444e Python 3.10.12 2023-06-06 23:30:33 +01:00
Miss Islington (bot)
b7fd286c3b
[3.10] gh-89412: Add missing attributes (added in 3.10) to traceback module docs (GH-105046) (#105329)
(cherry picked from commit a4f72fa39a)

Co-authored-by: Jakub Kuczys <me@jacken.men>
2023-06-05 19:02:31 +02:00
Miss Islington (bot)
f9d2a109bb
[3.10] gh-104472: Skip test_subprocess.ProcessTestCase.test_empty_env if ASAN is enabled (GH-104667) (#104669)
gh-104472: Skip `test_subprocess.ProcessTestCase.test_empty_env` if ASAN is enabled (GH-104667)

Skip test_subprocess.ProcessTestCase.test_empty_env if ASAN is enabled.
(cherry picked from commit c3f43bfb4b)

Co-authored-by: chgnrdv <52372310+chgnrdv@users.noreply.github.com>
2023-05-19 14:22:44 -07:00
Miss Islington (bot)
f48a96a280
[3.10] [3.11] gh-102153: Start stripping C0 control and space chars in urlsplit (GH-102508) (GH-104575) (#104592)
gh-102153: Start stripping C0 control and space chars in `urlsplit` (GH-102508)

`urllib.parse.urlsplit` has already been respecting the WHATWG spec a bit GH-25595.

This adds more sanitizing to respect the "Remove any leading C0 control or space from input" [rule](https://url.spec.whatwg.org/GH-url-parsing:~:text=Remove%20any%20leading%20and%20trailing%20C0%20control%20or%20space%20from%20input.) in response to [CVE-2023-24329](https://nvd.nist.gov/vuln/detail/CVE-2023-24329).

I simplified the docs by eliding the state of the world explanatory
paragraph in this security release only backport.  (people will see
that in the mainline /3/ docs)

---------

(cherry picked from commit 2f630e1ce1)
(cherry picked from commit 610cc0ab1b)

Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Co-authored-by: Illia Volochii <illia.volochii@gmail.com>
Co-authored-by: Gregory P. Smith [Google] <greg@krypto.org>
2023-05-17 16:06:06 -07:00
Matěj Cepl
425065bb00
[3.10] gh-102950: Implement PEP 706 – Filter for tarfile.extractall (GH-102953) (GH-104128)
- Backport b52ad18a76
- Backport c8c3956d90
- Remove the DeprecationWarning
- Adjust docs
- Remove new `__all__` entries

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2023-05-10 13:43:00 +02:00