Commit graph

3882 commits

Author SHA1 Message Date
Pablo Galindo
3358f9abf4
Post 3.10.18 2025-06-03 20:02:06 +01:00
Pablo Galindo
88663ef89b
Python 3.10.18 2025-06-03 19:23:41 +01:00
Serhiy Storchaka
ab9893c406
[3.10] gh-133767: Fix use-after-free in the unicode-escape decoder with an error handler (GH-129648) (GH-133944) (GH-134345)
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)
(cherry picked from commit 0c33e5baed)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-02 17:55:48 +02:00
Pablo Galindo
6322edd260
Post 3.10.17 2025-04-08 14:27:31 +01:00
Pablo Galindo
26ee8cad13
Python 3.10.17 2025-04-08 13:10:59 +01:00
Pablo Galindo
362fc98c03 Post 3.10.16 2024-12-03 13:35:58 -05:00
Pablo Galindo
890778604a Python 3.10.16 2024-12-03 12:27:57 -05:00
Pablo Galindo
0c5fc27217 Post 3.10.15 2024-09-07 01:46:51 +01:00
Pablo Galindo
ffee63f344 Python 3.10.15 2024-09-07 01:20:06 +01:00
Łukasz Langa
83518b3511
Post 3.10.14 2024-03-20 00:40:17 +01:00
Łukasz Langa
976ea78599
Python 3.10.14 2024-03-19 22:46:16 +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
Pablo Galindo
fc382d3dd0 Post 3.10.13 2023-08-24 14:21:57 +01:00
Pablo Galindo
49965601d6 Python 3.10.13 2023-08-24 13:46:25 +01:00
Pablo Galindo
a23ff66a59 Post 3.10.12 2023-06-06 23:49:22 +01:00
Pablo Galindo
b4e48a444e Python 3.10.12 2023-06-06 23:30:33 +01:00
Pablo Galindo
20f4222fe3 Post 3.10.11 2023-04-05 12:20:17 +01:00
Pablo Galindo
7d4cc5aa85 Python 3.10.11 2023-04-04 22:57:15 +01:00
Pablo Galindo
d7c60e361f Post 3.10.10 2023-02-08 09:59:32 +00:00
Pablo Galindo
aad5f6a891 Python 3.10.10 2023-02-07 12:05:45 +00:00
Pablo Galindo
3843973cfd Post 3.10.9 2022-12-06 21:18:42 +00:00
Pablo Galindo
1dd9be6584 Python 3.10.9 2022-12-06 18:31:21 +00:00
Pablo Galindo
af63fa0dcd
Post 3.10.8 2022-10-11 18:27:10 +01:00
Pablo Galindo
aaaf517424
Python 3.10.8 2022-10-11 12:21:44 +01:00
Miss Islington (bot)
437032e313
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:53 -07:00
Pablo Galindo
0abc6a3493
Post 3.10.7 2022-09-06 10:18:34 +01:00
Pablo Galindo
6cc6b13308
Python 3.10.7 2022-09-05 14:00:02 +01:00
Gregory P. Smith
eace09e63e
[3.10] gh-95778: Correctly pre-check for int-to-str conversion (GH-96537) (#96563)
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:54:56 -07:00
Gregory P. Smith
8f0fa4bd10
[3.10] gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96501)
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:51:49 -07:00
Miss Islington (bot)
83bde57f6e
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:05:37 -07:00
Pablo Galindo
ee2f45a061
Post 3.10.6 2022-08-02 11:05:09 +01:00
Pablo Galindo
9c7b4bd164
Python 3.10.6 2022-08-01 21:25:27 +01:00
Miss Islington (bot)
968b238b5e
[3.11] gh-93741: Add private C API _PyImport_GetModuleAttrString() (GH-93742) (GH-93792)
It combines PyImport_ImportModule() and PyObject_GetAttrString()
and saves 4-6 lines of code on every use.

Add also _PyImport_GetModuleAttr() which takes Python strings as arguments.
(cherry picked from commit 6fd4c8ec77)
(cherry picked from commit d42b3689f4)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-06-16 00:19:29 -07:00
Pablo Galindo
1b7996cf73
Post 3.10.5 2022-06-06 18:13:35 +01:00
Pablo Galindo
f377153967
Python 3.10.5 2022-06-06 12:53:30 +01:00
Miss Islington (bot)
a4bea26ee4
gh-93065: Fix HAMT to iterate correctly over 7-level deep trees (GH-93066) (GH-93146)
Also while there, clarify a few things about why we reduce the hash to 32 bits.

Co-authored-by: Eli Libman <eli@hyro.ai>
Co-authored-by: Yury Selivanov <yury@edgedb.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>

(cherry picked from commit c1f5c903a7)
2022-05-24 10:52:29 +02:00
Pablo Galindo
4d37dc69bd
Post 3.10.4 2022-03-24 10:30:34 +00:00
Pablo Galindo
9d38120e33
Python 3.10.4 2022-03-23 20:12:04 +00:00
Pablo Galindo
b7c6119377
Post 3.10.3 2022-03-16 14:30:58 +00:00
Pablo Galindo
a342a49189
Python 3.10.3 2022-03-16 11:27:11 +00:00
Pablo Galindo Salgado
5b58db7529
[3.10] bpo-46521: Fix codeop to use a new partial-input mode of the parser (GH-31010). (GH-31213)
(cherry picked from commit 69e10976b2)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2022-02-08 12:25:15 +00:00
Pablo Galindo
d5c4ccfe0d
Post 3.10.2 2022-01-14 21:11:47 +00:00
Pablo Galindo
a58ebcc701
Python 3.10.2 2022-01-13 18:52:14 +00:00
Victor Stinner
72c260cf0c
[3.10] bpo-46006: Revert "bpo-40521: Per-interpreter interned strings (GH-20085)" (GH-30422) (GH-30425)
This reverts commit ea251806b8.

Keep "assert(interned == NULL);" in _PyUnicode_Fini(), but only for
the main interpreter.

Keep _PyUnicode_ClearInterned() changes avoiding the creation of a
temporary Python list object.

Leave the PyInterpreterState structure unchanged to keep the ABI
backward compatibility with Python 3.10.0: rename the "interned"
member to "unused_interned".

(cherry picked from commit 35d6540c90)
2022-01-06 16:12:28 +01:00
Miss Islington (bot)
438817fdd5
bpo-46042: Improve SyntaxError locations in the symbol table (GH-30059) (GH-30064)
(cherry picked from commit 59435eea08)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-12-12 01:24:12 +00:00
Pablo Galindo
bf1812ef61
Post 3.10.1 2021-12-06 18:52:20 +00:00
Pablo Galindo
2cd268a3a9
Python 3.10.1 2021-12-06 18:23:39 +00:00
Victor Stinner
ce5a6460ae
bpo-39026: Fix Python.h when building with Xcode (GH-29488) (GH-29732)
Fix Python.h to build C extensions with Xcode: remove a relative
include from Include/cpython/pystate.h.

(cherry picked from commit 4ae26b9c1d)
2021-11-25 13:35:22 +01:00
Miss Islington (bot)
cd85d91bc6
bpo-45893: Add missing extern C to initconfig.h (GH-29761)
Co-authored-by: Steve Dower <steve.dower@python.org>
(cherry picked from commit f4afc53bf6)

Co-authored-by: Christian Heimes <christian@python.org>
2021-11-24 13:57:41 -08:00
Łukasz Langa
904af3de2b
[3.10] bpo-45848: Allow the parser to get error lines from encoded files (GH-29646) (GH-29661)
(cherry picked from commit fdcc46d955)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-11-20 16:34:56 +01:00