0
0
mirror of https://github.com/python/cpython.git synced 2024-11-24 17:47:13 +01:00
Commit Graph

4304 Commits

Author SHA1 Message Date
Pablo Galindo
8b275e77d2 Post 3.11.10 2024-09-07 02:34:11 +01:00
Pablo Galindo
0c47759eee Python 3.11.10 2024-09-07 02:03:31 +01:00
Pablo Galindo
9a40444a76 Post 3.11.9 2024-04-02 14:37:54 +01:00
Pablo Galindo
de54cf5be3 Python 3.11.9 2024-04-02 09:25:04 +01:00
Serhiy Storchaka
7323c4dd07
[3.11] gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit platforms (GH-117064) (GH-117070) (GH-117075)
(cherry picked from commit da2f9d1417)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
(cherry picked from commit 519b2ae22b)
2024-03-21 09:43:42 +00:00
Sebastian Pipping
fc9da96274
[3.11] gh-115398: Expose Expat >=2.6.0 reparse deferral API (CVE-2023-52425) (GH-115623) (#116268)
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 #115138 (comment) .

- Please treat as a security fix related to CVE-2023-52425.

(cherry picked from commit 6a95676)
(cherry picked from commit 73807eb)
(cherry picked from commit eda2963)

---------

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-06 14:17:02 -08:00
Pablo Galindo
c43bd4b934 Post 3.11.8 2024-02-06 23:38:18 +00:00
Pablo Galindo
db85d51d3e Python 3.11.8 2024-02-06 21:21:21 +00:00
Serhiy Storchaka
4b358d754c
[3.11] gh-106905: Use separate structs to track recursion depth in each PyAST_mod2obj call. (GH-113035) (GH-113472) (GH-113476)
(cherry picked from commit 48c49739f5)
(cherry picked from commit d58a5f453f)

Co-authored-by: Yilei Yang <yileiyang@google.com>
Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
2023-12-25 20:40:33 +00:00
Pablo Galindo
4c368bc0ce Post 3.11.7 2023-12-04 21:49:55 +00:00
Pablo Galindo
fa7a6f2303 Python 3.11.7 2023-12-04 17:56:29 +00:00
Lysandros Nikolaou
1af7b7db0d
[3.11] gh-107450: Check for overflow in the tokenizer and fix overflow test (GH-110832) (#110939)
(cherry picked from commit a1ac5590e0)

Co-authored-by: Filipe Laíns <lains@riseup.net>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-18 00:34:56 +02:00
Pablo Galindo
914ffb40d0 Post 3.11.6 2023-10-02 17:23:15 +01:00
Pablo Galindo
8b6ee5ba3b Python 3.11.6 2023-10-02 14:29:10 +01:00
Victor Stinner
82a18069a1
[3.11] gh-108987: Fix _thread.start_new_thread() race condition (#109135) (#109272)
gh-108987: Fix _thread.start_new_thread() race condition (#109135)

Fix _thread.start_new_thread() race condition. If a thread is created
during Python finalization, the newly spawned thread now exits
immediately instead of trying to access freed memory and lead to a
crash.

thread_run() calls PyEval_AcquireThread() which checks if the thread
must exit. The problem was that tstate was dereferenced earlier in
_PyThreadState_Bind() which leads to a crash most of the time.

Move _PyThreadState_CheckConsistency() from thread_run() to
_PyThreadState_Bind().

(cherry picked from commit 517cd82ea7)
2023-09-11 19:33:08 +02:00
Victor Stinner
b55cf2c2d8
[3.11] gh-104690: thread_run() checks for tstate dangling pointer (#109056) (#109134)
gh-104690: thread_run() checks for tstate dangling pointer (#109056)

thread_run() of _threadmodule.c now calls
_PyThreadState_CheckConsistency() to check if tstate is a dangling
pointer when Python is built in debug mode.

Rename ceval_gil.c is_tstate_valid() to
_PyThreadState_CheckConsistency() to reuse it in _threadmodule.c.

(cherry picked from commit f63d37877a)
2023-09-08 11:10:33 +00:00
Miss Islington (bot)
b30c83eb21
[3.11] [3.12] gh-63760: Don't declare gethostname() on Solaris (GH-108817) (GH-108824) (#108832)
[3.12] gh-63760: Don't declare gethostname() on Solaris (GH-108817) (GH-108824)

gh-63760: Don't declare gethostname() on Solaris (GH-108817)

Since 2005, Solaris defines gethostname(). socketmodule.c no longer
has to define gethostname() for Solaris.

Oracle Solaris and OpenSolaris have patches to remove the
gethostname() definition in Python:

* https://github.com/oracle/solaris-userland/blob/master/components/python/python37/patches/15-gethostname.patch
* https://github.com/OpenIndiana/oi-userland/blob/oi/hipster/components/python/python37/patches/15-gethostname.patch
* https://github.com/omniosorg/omnios-build/blob/master/build/python27/patches/24-gethostname.patch

(cherry picked from commit 7269916cd7)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
(cherry picked from commit 0e6d582b3b)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-03 08:53:02 +02:00
Pablo Galindo
ea77520094 Post 3.11.5 2023-08-24 20:31:59 +01:00
Pablo Galindo
cce6ba91b3 Python 3.11.5 2023-08-24 13:09:18 +01:00
Steve Dower
ccf81e1088
[3.11] gh-106242: Fix path truncation in os.path.normpath (GH-106816) (#107982)
Co-authored-by: Finn Womack <flan313@gmail.com>
2023-08-15 19:07:52 +02:00
Miss Islington (bot)
2ce8e133d0
[3.11] gh-107226: PyModule_AddObjectRef() should only be in the limited API 3.10 (GH-107227) (GH-107261)
(cherry picked from commit 698b015135)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-07-25 23:02:06 +03:00
Serhiy Storchaka
fced79f91e
[3.11] gh-86493: Fix possible leaks in some modules initialization (GH-106768) (GH-106855) (GH-106863)
[3.11] [3.12] gh-86493: Fix possible leaks in some modules initialization (GH-106768) (GH-106855)

Fix _ssl, _stat, _testinternalcapi, _threadmodule, cmath, math, posix, time.
(cherry picked from commit 3e65baee72).
(cherry picked from commit a423ddbdea)
2023-07-19 09:40:38 +03:00
Pablo Galindo
5103df46e0 Post 3.11.4 2023-06-07 09:37:03 +01:00
Pablo Galindo
d2340ef257 Python 3.11.4 2023-06-06 23:00:27 +01:00
Lysandros Nikolaou
a09d3901a5
[3.11] gh-96670: Raise SyntaxError when parsing NULL bytes (GH-97594) (#104195) 2023-05-07 11:12:04 +01:00
Miss Islington (bot)
15ffcf76e1
[3.11] gh-104018: remove unused format "z" handling in string formatfloat() (GH-104107) (#104260)
gh-104018: remove unused format "z" handling in string formatfloat() (GH-104107)

This is a cleanup overlooked in PR GH-104033.
(cherry picked from commit 69621d1b09)

Co-authored-by: John Belmonte <john@neggie.net>
2023-05-07 05:06:06 +00:00
Miss Islington (bot)
851e74441e
gh-99069: Consolidate checks for static_assert (GH-94766)
Several platforms don't define the static_assert macro despite having
compiler support for the _Static_assert keyword. The macro needs to be
defined since it is used unconditionally in the Python code. So it
should always be safe to define it if undefined and not in C++11 (or
later) mode.

Hence, remove the checks for particular platforms or libc versions,
and just define static_assert anytime it needs to be defined but isn't.
That way, all platforms that need the fix will get it, regardless of
whether someone specifically thought of them.

Also document that certain macOS versions are among the platforms that
need this.

The C2x draft (currently expected to become C23) makes static_assert
a keyword to match C++. So only define the macro for up to C17.

(cherry picked from commit 96e1901a59)

Co-authored-by: Joshua Root <jmr@macports.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-04-05 08:44:13 -07:00
Pablo Galindo
ff844aa16e Post 3.11.3 2023-04-05 12:16:08 +01:00
Pablo Galindo
f3909b8bc8 Python 3.11.3 2023-04-04 23:22:17 +01:00
Pablo Galindo
e396888a6e Post 3.11.2 2023-02-08 09:55:26 +00:00
Pablo Galindo
878ead1ac1 Python 3.11.2 2023-02-07 13:37:51 +00:00
Miss Islington (bot)
d2aaf818ae
[3.11] gh-101037: Fix potential memory underallocation for zeros of int subtypes (GH-101038) (#101219)
gh-101037: Fix potential memory underallocation for zeros of int subtypes (GH-101038)

This PR fixes object allocation in long_subtype_new to ensure that there's at least one digit in all cases, and makes sure that the value of that digit is copied over from the source long.

Needs backport to 3.11, but not any further: the change to require at least one digit was only introduced for Python 3.11.

Fixes GH-101037.
(cherry picked from commit 401fdf9c85)

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
2023-01-21 10:54:09 +00:00
Bill Fisher
57e727af3f
[3.11] gh-99110: Initialize frame->previous in init_frame to fix segmentation fault (GH-100182) (#100478)
(cherry picked from commit 88d565f32a)

Co-authored-by: Bill Fisher <william.w.fisher@gmail.com>
2022-12-24 11:17:10 +05:30
Pablo Galindo
fbc3e1ed90 Post 3.11.1 2022-12-06 21:07:58 +00:00
Pablo Galindo
a7a450f84a Python 3.11.1 2022-12-06 19:05:27 +00:00
Victor Stinner
0c6b3a2d8e
[3.11] Revert "[3.11] gh-98724: Fix Py_CLEAR() macro side effects (#99100)" (#99573)
Revert "gh-98724: Fix Py_CLEAR() macro side effects (#99100) (#99288)"

This reverts commit 1082890857.
2022-11-21 18:01:10 +01:00
Victor Stinner
1082890857
gh-98724: Fix Py_CLEAR() macro side effects (#99100) (#99288)
The Py_CLEAR(), Py_SETREF() and Py_XSETREF() macros now only evaluate
their argument once. If an argument has side effects, these side
effects are no longer duplicated.

Add test_py_clear() and test_py_setref() unit tests to _testcapi.

(cherry picked from commit c03e05c2e7)
2022-11-09 16:29:23 +01:00
Pablo Galindo Salgado
b3cafb60af
[3.11] Fix v3.11.0 release merge problems (GH-98622)
When merging the v3.11.0 tag into 3.11, some files were incorrectly updated and some others were not properly deleted.

Automerge-Triggered-By: GH:pablogsal
2022-10-24 16:30:06 -07:00
Pablo Galindo
69b6b56d85 Python 3.11.0
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEz9yiRbEEPPKl+Xhl/+h0BBaL2EcFAmNWzOwACgkQ/+h0BBaL
 2EcepxAAmZLGMrL4D7Zxzo6N2ezkuiuoQH4JvxIUaB7cjU5h0GSUFlmcJQCHhCwk
 AvToQrmH/7uuuEZKST1fomtUE83wudfHhX2t+CMBdbLG1hIwhTfLNMTqFhONturF
 XlkVUcva1i9XrYZPLl1pIcBf1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4VeSSYy/OfEpwy
 8Hx1YitMyORF3HkGWa+pPYPNaIOw4S/EQQPYd5osg3NnknYjkkKZZaliq7EZra7c
 GANPJamXhHREQyhux9KeiYZer3SU3CSXopyxm8ClcBZJAiAOjhAdeOk+Q4Ta9T6+
 gRWBOrelroyFTWHsOd8V7gSz3XJNuAzlNZ/+1Oj/7Em+5DGLFcxJrZGLxn+hruZ5
 GPK9IQXbURAuxqVrqCzw2tzf/NzJr0fs4QDYEVI95pfLjzk1tuJ5WR6zFNC0COK2
 qw8TTvXglsvHqVMnK8u73GVSTv1UGYqbQH9uAeEikAQYr3TTdZo=
 =dsZm
 -----END PGP SIGNATURE-----

Merge tag 'v3.11.0' into 3.11

Python 3.11.0
2022-10-24 20:29:24 +01:00
Pablo Galindo
deaf509e8f
Python 3.11.0 2022-10-24 18:35:39 +01:00
Pablo Galindo
b0925211f4
Post 3.11.0rc2 2022-10-22 20:04:32 +01:00
Miss Islington (bot)
4d1de87042
gh-96959: Update HTTP links which are redirected to HTTPS (GH-96961)
(cherry picked from commit db39050396)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-09-25 01:20:45 -07:00
Pablo Galindo
14adf4667e
Post 3.11.0rc2 2022-09-12 11:54:49 +01:00
Pablo Galindo
ed7c3ff156
Python 3.11.0rc2 2022-09-11 20:23:30 +01:00
Mark Shannon
e72f469e85
[3.11] GH-96569: Avoid undefined behavior (#96616)
Co-authored-by: Michael Droettboom <mdboom@gmail.com>
2022-09-08 12:00:04 +01:00
Miss Islington (bot)
8a776d1d51
gh-95778: Correctly pre-check for int-to-str conversion (GH-96537)
Converting a large enough `int` to a decimal string raises `ValueError` as expected. However, the raise comes _after_ the quadratic-time base-conversion algorithm has run to completion. For effective DOS prevention, we need some kind of check before entering the quadratic-time loop. Oops! =)

The quick fix: essentially we catch _most_ values that exceed the threshold up front. Those that slip through will still be on the small side (read: sufficiently fast), and will get caught by the existing check so that the limit remains exact.

The justification for the current check. The C code check is:
```c
max_str_digits / (3 * PyLong_SHIFT) <= (size_a - 11) / 10
```

In GitHub markdown math-speak, writing $M$ for `max_str_digits`, $L$ for `PyLong_SHIFT` and $s$ for `size_a`, that check is:
$$\left\lfloor\frac{M}{3L}\right\rfloor \le \left\lfloor\frac{s - 11}{10}\right\rfloor$$

From this it follows that
$$\frac{M}{3L} < \frac{s-1}{10}$$
hence that
$$\frac{L(s-1)}{M} > \frac{10}{3} > \log_2(10).$$
So
$$2^{L(s-1)} > 10^M.$$
But our input integer $a$ satisfies $|a| \ge 2^{L(s-1)}$, so $|a|$ is larger than $10^M$. This shows that we don't accidentally capture anything _below_ the intended limit in the check.

<!-- gh-issue-number: gh-95778 -->
* Issue: gh-95778
<!-- /gh-issue-number -->

Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
(cherry picked from commit b126196838)

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
2022-09-04 09:45:02 -07:00
Gregory P. Smith
f8b71da9aa
[3.11] gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96500)
Integer to and from text conversions via CPython's bignum `int` type is not safe against denial of service attacks due to malicious input. Very large input strings with hundred thousands of digits can consume several CPU seconds.

This PR comes fresh from a pile of work done in our private PSRT security response team repo.

This backports https://github.com/python/cpython/pull/96499 aka 511ca94520

Signed-off-by: Christian Heimes [Red Hat] <christian@python.org>
Tons-of-polishing-up-by: Gregory P. Smith [Google] <greg@krypto.org>
Reviews via the private PSRT repo via many others (see the NEWS entry in the PR).

<!-- gh-issue-number: gh-95778 -->
* Issue: gh-95778
<!-- /gh-issue-number -->

I wrote up [a one pager for the release managers](https://docs.google.com/document/d/1KjuF_aXlzPUxTK4BMgezGJ2Pn7uevfX7g0_mvgHlL7Y/edit#).
2022-09-02 09:48:57 -07:00
Miss Islington (bot)
1901ee7a52
gh-46845: clean up unused DK_IXSIZE (GH-96405)
(cherry picked from commit d21d2f0793)

Co-authored-by: Matthias Görgens <matthias.goergens@gmail.com>
2022-08-30 00:28:51 -07:00
Miss Islington (bot)
df9c12e287
Fix typo in internal/pycore_atomic.h (GH-95939)
(cherry picked from commit 8281cbddc6)

Co-authored-by: fluesvamp <105884371+fluesvamp@users.noreply.github.com>
2022-08-12 21:04:06 -07:00
Pablo Galindo
19eed66d2b
Post 3.11.0rc1 2022-08-08 14:07:31 +01:00