Commit graph

3653 commits

Author SHA1 Message Date
Łukasz Langa
f690a6f1c2
Post 3.9.23 2025-06-03 21:14:38 +02:00
Łukasz Langa
865270262a
Python 3.9.23 2025-06-03 20:47:52 +02:00
Serhiy Storchaka
8d35fd1b34
[3.9] gh-133767: Fix use-after-free in the unicode-escape decoder with an error handler (GH-129648) (GH-133944) (#134346)
* [3.9] gh-133767: Fix use-after-free in the unicode-escape decoder with an error handler (GH-129648) (GH-133944)

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)
(cherry picked from commit 8b528cacbb)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-02 17:58:01 +02:00
Łukasz Langa
558e27abf1
Post 3.9.22 2025-04-08 19:30:37 +02:00
Łukasz Langa
05c5549224
Python 3.9.22 2025-04-08 17:21:55 +02:00
Łukasz Langa
340a82d9cf
Post 3.9.21 2024-12-03 19:25:02 +01:00
Łukasz Langa
f3994ade31
Python 3.9.21 2024-12-03 18:50:13 +01:00
Łukasz Langa
8b9a8e0e08
Post 3.9.20. 2024-09-06 22:34:30 +02:00
Łukasz Langa
8c3f7946ec
Python 3.9.20 2024-09-06 21:03:56 +02:00
Łukasz Langa
a04a0f6585
Post 3.9.19 2024-03-19 17:18:11 +01:00
Łukasz Langa
882f62bd93
Python 3.9.19 2024-03-19 16:48:02 +01:00
Sebastian Pipping
200762426b
[3.9] gh-115398: Expose Expat >=2.6.0 reparse deferral API (CVE-2023-52425) (GH-115623) (GH-116272)
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:03:30 +01:00
Łukasz Langa
cf69231a70
Post 3.9.18 2023-08-24 21:18:58 +02:00
Łukasz Langa
376d66eb50
Python 3.9.18 2023-08-24 19:59:28 +02:00
Łukasz Langa
1528b420b3
Post 3.9.17 2023-06-06 14:17:01 +02:00
Łukasz Langa
0d3cd4eb66
Python 3.9.17 2023-06-06 11:32:53 +02:00
Łukasz Langa
db577e29a6
Post 3.9.16 2022-12-06 19:50:26 +01:00
Łukasz Langa
595f9ccb0c
Python 3.9.16 2022-12-06 18:59:46 +01:00
Łukasz Langa
bd4e5320e5
Post 3.9.15 2022-10-11 17:38:29 +02:00
Łukasz Langa
7e28154196
Python 3.9.15 2022-10-11 16:48:37 +02:00
Łukasz Langa
83886261fa
Post 3.9.14 2022-09-06 20:47:37 +02:00
Łukasz Langa
816066f497
Python 3.9.14 2022-09-06 19:26:16 +02:00
Gregory P. Smith
cec1e9dfd7
[3.9] gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96502)
* Correctly pre-check for int-to-str conversion (#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>
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
2022-09-05 11:21:03 +02:00
Miss Islington (bot)
95c9c2b9cb
gh-93065: Fix HAMT to iterate correctly over 7-level deep trees (GH-93066) (#93147)
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:49 +02:00
Łukasz Langa
ab003d0ba4
Post 3.9.13 2022-05-17 19:06:39 +02:00
Łukasz Langa
6de2ca5339
Python 3.9.13 2022-05-17 13:12:56 +02:00
Łukasz Langa
6f345d3633
Post 3.9.12 2022-03-24 01:26:30 +01:00
Łukasz Langa
b28265d7e6
Python 3.9.12 2022-03-23 22:12:08 +01:00
Łukasz Langa
665a399e1d
Post 3.9.11, take two 2022-03-16 16:05:47 +01:00
Łukasz Langa
2de452f8bf
Python 3.9.11, take two 2022-03-16 14:03:13 +01:00
Łukasz Langa
27f6386ffd
Post 3.9.11 2022-03-15 23:43:30 +01:00
Łukasz Langa
0f0c55c9f0
Python 3.9.11 2022-03-15 21:47:24 +01:00
Łukasz Langa
4de57db294
Post 3.9.10 2022-01-14 22:49:33 +01:00
Łukasz Langa
f2f3f53782
Python 3.9.10 2022-01-13 22:21:23 +01:00
Victor Stinner
92631a4144
bpo-39026: Fix Python.h when building with Xcode (GH-29488) (GH-29776)
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-26 10:59:31 +01:00
Mark Shannon
4296396db0
[3.9] bpo-45806: Fix recovery from stack overflow for 3.9. Again. (GH-29640)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-11-19 19:51:50 +01:00
Łukasz Langa
3bb2566ce8
Post 3.9.9 2021-11-15 22:41:03 +01:00
Łukasz Langa
ccb0e6a345
Python 3.9.9 2021-11-15 18:43:00 +01:00
Łukasz Langa
5fdf7912ca
Post 3.9.8 2021-11-05 22:21:27 +01:00
Łukasz Langa
bb3fdcfe95
Python 3.9.8 2021-11-05 20:21:41 +01:00
Serhiy Storchaka
6848602806
bpo-45467: Fix IncrementalDecoder and StreamReader in the "raw-unicode-escape" codec (GH-28944) (GH-28953)
They support now splitting escape sequences between input chunks.

Add the third parameter "final" in codecs.raw_unicode_escape_decode().
It is True by default to match the former behavior.

(cherry picked from commit 39aa98346d)
2021-10-14 21:23:52 +03:00
Serhiy Storchaka
7c722e32bf
[3.9] bpo-45461: Fix IncrementalDecoder and StreamReader in the "unicode-escape" codec (GH-28939) (GH-28945)
They support now splitting escape sequences between input chunks.

Add the third parameter "final" in codecs.unicode_escape_decode().
It is True by default to match the former behavior.
(cherry picked from commit c96d1546b1)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2021-10-14 20:03:29 +03:00
Christian Clauss
6c97b03cf6
[3.9] Fix typos in the Include directory (GH-28745) (GH-28788)
(cherry picked from commit 8e8f752217)
2021-10-07 06:01:05 -07:00
Serhiy Storchaka
e9ce081ec7
[3.9] Remove trailing spaces (GH-28710) 2021-10-03 20:04:38 +03:00
Miss Islington (bot)
9626ac8b74
closes bpo-44751: Move crypt.h include from public header to _cryptmodule (GH-27394)
Automerge-Triggered-By: GH:benjaminp
(cherry picked from commit 196998e220)

Co-authored-by: Geoffrey Thomas <geofft@ldpreload.com>
2021-09-29 13:47:58 -07:00
Łukasz Langa
5482db5800
[3.9] [codemod] Fix non-matching bracket pairs (GH-28473) (GH-28512)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>.
(cherry picked from commit 8f943ca257)

Co-authored-by: Mohamad Mansour <66031317+mohamadmansourX@users.noreply.github.com>
2021-09-22 17:32:04 +02:00
Miss Islington (bot)
41c2374024
[3.9] bpo-45083: Include the exception class qualname when formatting an exception (GH-28119) (GH-28135)
* bpo-45083: Include the exception class qualname when formatting an exception (GH-28119)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
(cherry picked from commit b4b6342848)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-09-03 18:56:05 +02:00
Łukasz Langa
9ab2b48f2b
Post 3.9.7 2021-08-30 23:55:37 +02:00
Łukasz Langa
1016ef3790
Python 3.9.7 2021-08-30 21:02:15 +02:00
Miss Islington (bot)
298ee657ab
bpo-44184: Fix subtype_dealloc() for freed type (GH-26274)
Fix a crash at Python exit when a deallocator function removes the
last strong reference to a heap type.

Don't read type memory after calling basedealloc() since
basedealloc() can deallocate the type and free its memory.

_PyMem_IsPtrFreed() argument is now constant.
(cherry picked from commit 615069eb08)

Co-authored-by: Victor Stinner <vstinner@python.org>
2021-07-15 16:36:51 -07:00