Commit graph

48031 commits

Author SHA1 Message Date
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
Miss Islington (bot)
cfa4295cd1
[3.10] gh-99889: Fix directory traversal security flaw in uu.decode() (GH-104096) (#104330)
gh-99889: Fix directory traversal security flaw in uu.decode() (GH-104096)

* Fix directory traversal security flaw in uu.decode()
* also check absolute paths and os.altsep
* Add a regression test.

---------

(cherry picked from commit 0aeda29793)


 [Google]

Co-authored-by: Sam Carroll <70000253+samcarroll42@users.noreply.github.com>
2023-05-09 09:46:47 -07:00
Miss Islington (bot)
d77e77c363
[3.10] gh-104049: do not expose on-disk location from SimpleHTTPRequestHandler (GH-104067) (#104119)
gh-104049: do not expose on-disk location from SimpleHTTPRequestHandler (GH-104067)

Do not expose the local server's on-disk location from `SimpleHTTPRequestHandler` when generating a directory index. (unnecessary information disclosure)

---------

(cherry picked from commit c7c3a60c88)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-09 15:21:53 +00:00
Steve Dower
e277266a92
gh-103935: Use io.open_code() when executing code in trace and profile modules (GH-103947)
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
2023-04-27 22:44:07 +01:00
Pablo Galindo
7d4cc5aa85 Python 3.10.11 2023-04-04 22:57:15 +01:00
Miss Islington (bot)
9a8ce95748
gh-103109: Document ignore_warnings() test support helper (GH-103110)
(cherry picked from commit 32937d6aa4)

Co-authored-by: Charlie Zhao <zhaoyu_hit@qq.com>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2023-04-02 15:38:58 -07:00
Miss Islington (bot)
3a27be7952
[3.10] gh-103112: Add http.client.HTTPResponse.read docstring and fix pydoc output (GH-103113) (#103120)
(cherry picked from commit d052a383f1)

Co-authored-by: Bernhard Wagner <github.comNotification20120125@xmlizer.net>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Éric <merwok@netwok.org>
2023-03-29 18:30:27 -04:00
Miss Islington (bot)
5ae5ea8375
[3.10] GH-87235: Make sure "python /dev/fd/9 9</path/to/script.py" works on macOS (GH-99768) (#99817)
On macOS all file descriptors for a particular file in /dev/fd
share the same file offset, that is ``open("/dev/fd/9", "r")`` behaves
more like ``dup(9)`` than a regular open.

This causes problems when a user tries to run "/dev/fd/9" as a script
because zipimport changes the file offset to try to read a zipfile
directory. Therefore change zipimport to reset the file offset after
trying to read the zipfile directory.
(cherry picked from commit d08fb25769)

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>

* Regen zipimport

---------

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-03-28 14:13:37 +02:00
Miss Islington (bot)
d445147dfa
[3.10] gh-88233: zipfile: handle extras after a zip64 extra (GH-96161) (#102087)
Previously, any data _after_ the zip64 extra would be removed.

With many new tests.

Fixes GH-88233
(cherry picked from commit 59e86caca8)

Co-authored-by: Tim Hatch <tim@timhatch.com>
2023-03-28 10:58:51 +02:00
Pradyun Gedam
3288923b7a
[3.10] gh-101997: Update bundled pip version to 23.0.1 (GH-101998). (#102241)
(cherry picked from commit 89d9ff0f48)
2023-03-28 10:57:55 +02:00
Miss Islington (bot)
b5bf6c1b22
[3.10] GH-95494: Fix transport EOF handling in OpenSSL 3.0 (GH-95495) (#103007)
GH-25309 enabled SSL_OP_IGNORE_UNEXPECTED_EOF by default, with a comment
that it restores OpenSSL 1.1.1 behavior, but this wasn't quite right.
That option causes OpenSSL to treat transport EOF as the same as
close_notify (i.e. SSL_ERROR_ZERO_RETURN), whereas Python actually has
distinct SSLEOFError and SSLZeroReturnError exceptions. (The latter is
usually mapped to a zero return from read.) In OpenSSL 1.1.1, the ssl
module would raise them for transport EOF and close_notify,
respectively. In OpenSSL 3.0, both act like close_notify.

Fix this by, instead, just detecting SSL_R_UNEXPECTED_EOF_WHILE_READING
and mapping that to the other exception type.

There doesn't seem to have been any unit test of this error, so fill in
the missing one. This had to be done with the BIO path because it's
actually slightly tricky to simulate a transport EOF with Python's fd
based APIs. (If you instruct the server to close the socket, it gets
confused, probably because the server's SSL object is still referencing
the now dead fd?)
(cherry picked from commit 420bbb783b)

Co-authored-by: David Benjamin <davidben@google.com>
2023-03-27 16:14:24 +02:00
Miss Islington (bot)
d3b4d3ace9
gh-102980: Add tests for pdf's display, alias and where commands (GH-102981)
(cherry picked from commit ded9a7fc19)

Co-authored-by: gaogaotiantian <gaogaotiantian@hotmail.com>
2023-03-24 14:09:11 -07:00
Miss Islington (bot)
0a2b63f6ad
[3.10] gh-96931: Fix incorrect results in ssl.SSLSocket.shared_ciphers (GH-96932) (#102919)
gh-96931: Fix incorrect results in ssl.SSLSocket.shared_ciphers (GH-96932)
(cherry picked from commit af9c34f6ef)

Co-authored-by: Benjamin Fogle <benfogle@gmail.com>
2023-03-24 13:33:32 +01:00
Alex Waygood
4531fd0cea
[3.10] gh-102947: Improve traceback when calling fields() on a non-dataclass (#102948) (#102954) 2023-03-23 15:13:05 +00:00
Nikita Sobolev
e732a85934
[3.10] gh-102721: Improve coverage of _collections_abc._CallableGenericAlias (GH-102790)
This is a manual backport of https://github.com/python/cpython/pull/102722 but without `typing.py` changes and without `TypeVarTuple` case, because it was added in 3.11

Automerge-Triggered-By: GH:AlexWaygood
2023-03-17 13:11:58 -07:00
Miss Islington (bot)
97812403bf
gh-94440: Fix issue of ProcessPoolExecutor shutdown hanging (GH-94468)
Fix an issue of concurrent.futures ProcessPoolExecutor shutdown hanging.

(cherry picked from commit 2dc94634b5)

Co-authored-by: yonatanp <yonatan.perry@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-03-15 22:08:11 -07:00
Miss Islington (bot)
6f4df729bd
gh-101377: improving test_locale_calendar_formatweekday of calendar (GH-101378)
---------

(cherry picked from commit 5e0865f22e)

Co-authored-by: Andre Hora <andrehora@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2023-03-14 19:59:49 -07:00
Irit Katriel
d4f8fafd2d
[3.10] GH-101673: Fix pdb bug where local variable changes are lost after longlist (#101674) (#102633)
GH-101673: Fix pdb bug where local variable changes are lost after longlist (#101674)

(cherry picked from commit 5d677c556f)

Co-authored-by: gaogaotiantian <gaogaotiantian@hotmail.com>
2023-03-13 14:24:01 +00:00
Miss Islington (bot)
5e10479ede
Fix broken link to MSDN (GH-102355)
(cherry picked from commit 9a8b66b58c)

Co-authored-by: 谭九鼎 <109224573@qq.com>
2023-03-13 06:41:01 -07:00
Miss Islington (bot)
a01ad527e7
gh-101100: Fix Sphinx warnings in turtle module (GH-102340)
(cherry picked from commit 78e4e6c3d7)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2023-03-13 04:11:34 -07:00