14578 Commits

Author SHA1 Message Date
Miss Islington (bot) 023ecbd01f [3.13] gh-148093: Raise binascii.Error from binascii.a2b_uu() on empty input (GH-149077) (GH-149349)
Instead of reading past the end of the empty buffer.
(cherry picked from commit 0c6d2f64c0)

Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
2026-05-04 10:06:25 +00:00
Serhiy Storchaka 0fd4fd4496 [3.13] gh-148529: Minor improvements of the struct module documentation (GH-148565) (GH-149072)
* Document that 's' and 'p' accept bytes and bytearray.
* Fix some footnotes.
* Clarify that "string" is a byte string.
* Fix the module docstring.
(cherry picked from commit 3e5a3cb2bd)
2026-04-27 20:22:47 +00:00
Stan Ulbrych feafd5f69c [3.13] gh-148735: Fix a UAF in Element.findtext() (GH-148738) (#148923)
(cherry picked from commit 0469e6d38d)
2026-04-25 10:38:14 +01:00
Miss Islington (bot) 813498411a [3.13] gh-148484: Fix memory leak of iterator in array.array constructor (GH-148523) (GH-148679)
(cherry picked from commit afde75664e)

Co-authored-by: Gleb Popov <gvpopov.dev@gmail.com>
2026-04-23 16:00:47 +02:00
Miss Islington (bot) 95633d2aad [3.13] gh-148808: Add boundary check to asyncio.AbstractEventLoop.sock_recvf… (GH-148809) (#148836)
gh-148808: Add boundary check to asyncio.AbstractEventLoop.sock_recvf… (GH-148809)
(cherry picked from commit 1274766d3c)

Co-authored-by: Seth Larson <seth@python.org>
2026-04-21 21:56:37 +05:30
Miss Islington (bot) c3cf71c336 [3.13] gh-148395: Fix a possible UAF in {LZMA,BZ2,_Zlib}Decompressor (GH-148396) (#148479)
gh-148395: Fix a possible UAF in `{LZMA,BZ2,_Zlib}Decompressor` (GH-148396)

Fix dangling input pointer after `MemoryError` in _lzma/_bz2/_ZlibDecompressor.decompress
(cherry picked from commit 8fc66aef6d)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-13 01:35:24 +00:00
Miss Islington (bot) 8e369d3645 [3.13] gh-145105: Fix crash in csv.reader with re-entrant iterator (GH-145106) (#148405)
gh-145105: Fix crash in csv.reader with re-entrant iterator (GH-145106)

When a custom iterator calls next() on the same csv.reader from
within __next__, the inner iteration sets self->fields to NULL.
The outer iteration then crashes in parse_save_field() by passing
NULL to PyList_Append.

Add a guard after PyIter_Next() to detect that fields was set to
NULL by a re-entrant call, and raise csv.Error instead of crashing.
(cherry picked from commit 20994b1809)

Co-authored-by: Ramin Farajpour Cami <ramin.blackhat@gmail.com>
2026-04-11 22:44:45 +00:00
Miss Islington (bot) 7fc8507f3d [3.13] gh-146613: Fix re-entrant use-after-free in itertools._grouper (GH-147962) (#148011)
gh-146613: Fix re-entrant use-after-free in `itertools._grouper` (GH-147962)
(cherry picked from commit fc7a188fe7)

Co-authored-by: Ma Yukun <68433685+TheSkyC@users.noreply.github.com>
2026-04-07 12:24:54 +02:00
Ramin Farajpour Cami 4c8d6f4f68 [3.13] gh-144984: Fix crash in Expat's ExternalEntityParserCreate error paths (GH-144992) (#146142)
* gh-144984: Fix crash in Expat's `ExternalEntityParserCreate` error paths (#144992)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* gh-144984: Skip test under tracerefs (GH-146218)

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2026-04-07 12:22:22 +02:00
Miss Islington (bot) df89a705d0 [3.13] gh-145883: Fix two heap-buffer-overflows in _zoneinfo (GH-145885) (#148086)
(cherry picked from commit fe9befc1ca)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-04 17:14:19 +01:00
Victor Stinner 01af34a364 [3.13] gh-143050: Correct PyLong_FromString() to use _PyLong_Negate() (#145901) (#147437)
The long_from_string_base() might return a small integer, when the
_pylong.py is used to do conversion.  Hence, we must be careful here to
not smash it "small int" bit by using the _PyLong_FlipSign().

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

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2026-03-31 17:06:38 +02:00
Serhiy Storchaka fc1c6446ce [3.13] gh-146615: Fix format specifiers in extension modules (GH-146617) (GH-146652) (GH-146658)
(cherry picked from commit 1c396e1821)
(cherry picked from commit 58c7259133)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2026-03-31 10:59:06 +00:00
Serhiy Storchaka def8ea08a1 [3.13] gh-146615: Fix format specifiers in test cextensions (GH-146618) (GH-146653)
(cherry picked from commit b7055533ab)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2026-03-31 08:38:59 +00:00
Miss Islington (bot) 472f1afa1c [3.13] gh-146083: Upgrade bundled Expat to 2.7.5 (GH-146085) (#146604)
(cherry picked from commit e39d84a37d)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2026-03-29 18:50:07 +01:00
Miss Islington (bot) 6fdf084644 [3.13] gh-146090: fix memory management of internal sqlite3 callback contexts (GH-146569) (#146596)
gh-146090: fix memory management of internal `sqlite3` callback contexts (GH-146569)
(cherry picked from commit aa6680775d)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-03-29 15:14:58 +02:00
Bénédikt Tran 59f33e82ff [3.13] gh-146080: fix a crash in SNI callbacks when the SSL object is gone (GH-146573) (#146598)
(cherry picked from commit 24db78c532)
2026-03-29 13:07:15 +00:00
Victor Stinner 04fe383602 [3.13] gh-146480: Add tests on _PyErr_SetKeyError() (#146486) (#146512)
gh-146480: Add tests on _PyErr_SetKeyError() (#146486)

(cherry picked from commit d4153a9f76)
2026-03-27 14:09:46 +01:00
Miss Islington (bot) de1644cd40 [3.13] gh-146059: Call fast_save_leave() in pickle save_frozenset() (GH-146173) (#146474)
gh-146059: Call fast_save_leave() in pickle save_frozenset() (GH-146173)

Add more pickle tests: test also nested structures.
(cherry picked from commit 5c0dcb3e0d)

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-27 08:47:53 +00:00
Miss Islington (bot) 2bb1ac2162 [3.13] gh-144837: Improve documentation for more collection methods (GH-144841) (GH-146484)
Use uniform standard signature syntax in the tutorial and in
the array and collections modules documentation.
(cherry picked from commit 17070f41d4)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-03-26 19:52:07 +00:00
Victor Stinner 921515f603 [3.13] gh-145633: Fix struct.pack('f') on s390x (#146422) (#146461)
gh-145633: Fix struct.pack('f') on s390x (#146422)

Use PyFloat_Pack4() to raise OverflowError.
Add more tests on packing/unpacking floats.


(cherry picked from commit 8de70b31c5)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2026-03-26 11:45:10 +00:00
Miss Islington (bot) 5a4959b92c [3.13] Fix unlikely potential reference leak in _locale._getdefaultlocale (GH-145250) (GH-145303)
It occurs in a code which perhaps never executed.
(cherry picked from commit 6ea84b2726)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-03-24 02:18:19 +00:00
Brij Kapadia 4e372077c5 [3.13] gh-144475: Fix reference management in partial_repr (GH-145362) (#145882)
(cherry picked from commit 671a953dd6)
2026-03-24 02:30:45 +01:00
Miss Islington (bot) 1f9958f909 [3.13] gh-145264: Do not ignore excess Base64 data after the first padded quad (GH-145267) (GH-146326) (GH-146348)
Base64 decoder (see binascii.a2b_base64(), base64.b64decode(), etc)
no longer ignores excess data after the first padded quad in non-strict
(default) mode.  Instead, in conformance with RFC 4648, it ignores the
pad character, "=", if it is present before the end of the encoded data.
(cherry picked from commit 4561f6418a)
(cherry picked from commit e31c551216)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-03-24 00:52:20 +01:00
Miss Islington (bot) 2f1e341b28 [3.13] gh-146245: Fix reference and buffer leaks via audit hook in socket module (GH-146248) (GH-146275)
(cherry picked from commit c30fae4bea)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
2026-03-22 11:51:54 +00:00
AN Long d513f9ef8f [3.13] gh-129849: Add tests for Py_tp_bases (GH-143208) (#146226)
(cherry picked from commit 6f8867a676)
2026-03-21 15:22:45 +05:30
Miss Islington (bot) cfd7f94c12 [3.13] gh-146092: Raise MemoryError on allocation failure in _zoneinfo (GH-146165) (#146224)
gh-146092: Raise MemoryError on allocation failure in _zoneinfo (GH-146165)
(cherry picked from commit 6450b1d142)

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-20 16:40:55 +00:00
Miss Islington (bot) c7d7e1c1a0 [3.13] gh-146093: Fix csv _set_str(): check if PyUnicode_DecodeASCII() failed (GH-146113) (#146131)
gh-146093: Fix csv _set_str(): check if PyUnicode_DecodeASCII() failed (GH-146113)

The function can fail on a memory allocation failure.

Bug reported by devdanzin.
(cherry picked from commit 724c7c8146)

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-18 17:45:47 +00:00
Miss Islington (bot) 450e9eaf73 [3.13] gh-146076: Fix crash when a ZoneInfo subclass is missing a _weak_cache (GH-146082) (GH-146115)
(cherry picked from commit 3b06d68d8a)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2026-03-18 15:20:45 +00:00
Miss Islington (bot) 196edfb06a [3.13] gh-145986: Avoid unbound C recursion in conv_content_model in pyexpat.c (CVE 2026-4224) (GH-145987) (#145996)
* gh-145986: Avoid unbound C recursion in `conv_content_model` in `pyexpat.c` (CVE 2026-4224) (GH-145987)

Fix C stack overflow (CVE-2026-4224) when an Expat parser
with a registered `ElementDeclHandler` parses inline DTD
containing deeply nested content model.

---------
(cherry picked from commit eb0e8be3a7)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Remvoe `skip_if_unlimited_stack_size` decorator

* Remove more decorators not on this branch

---------

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-03-16 14:39:27 +05:30
Stan Ulbrych 0b4f4c77f9 [3.13] gh-145783: Propagate errors raised in NEW_TYPE_COMMENT (GH-145784) (#145927) 2026-03-13 18:07:45 +00:00
Miss Islington (bot) cef423cbe2 [3.13] gh-145492: Fix defaultdict __repr__ infinite recursion (GH-145659) (GH-145746)
(cherry picked from commit 2d35f9bc1c)

Includes test fix-up from GH-145788
(cherry picked from commit aa4240ebea)

Co-authored-by: Thomas Kowalski <thom.kowa@gmail.com>
Co-authored-by: Matt Van Horn <mvanhorn@users.noreply.github.com>
2026-03-12 10:45:43 +01:00
Stan Ulbrych 37e9d846ff [3.13] Fix integer overflow for formats "s" and "p" in the struct module (GH-145750) (GH-145777)
(cherry picked from commit 4d0dce0c8d)
2026-03-10 17:44:10 +00:00
Miss Islington (bot) b5082d89cc [3.13] gh-145743: Fix inconsistency after calling Struct.__init__() with invalid format (GH-145744) (GH-145764)
Only set the format attribute after successful (re-)initialization.
(cherry picked from commit 3f33bf83e8)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-03-10 16:52:27 +00:00
krylosov-aa ba0d1b7dee [3.13] gh-145301: Fix double-free in hashlib initialization (GH-145321) (GH-145532)
(cherry picked from commit 6acaf659ef)
2026-03-10 14:59:37 +01:00
Ramin Farajpour Cami b2894626aa [3.13] gh-145623: Fix crashes on uninitialized struct.Struct objects (gh-145624) (GH-145631) 2026-03-09 17:41:45 +01:00
Miss Islington (bot) 1a73d5a35c [3.13] gh-145376: Fix refleak in queuemodule.c out-of-memory path (GH-145543) (#145621)
gh-145376: Fix refleak in `queuemodule.c` out-of-memory path (GH-145543)
(cherry picked from commit 0aeaaafac4)

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
2026-03-08 13:32:39 +05:30
Pieter Eendebak ae7206eb3b [3.13] gh-145376: Fix crashes in md5module.c (GH-145422) (#145611)
* gh-145376: Fix crashes in md5module.c

Fix a possible NULL pointer dereference in `md5module.c`.
This can only occur in error paths taken when the interpreter fails to allocate memory.

(cherry-picked from c1d7768321)

* 📜🤖 Added by blurb_it.

* Update Modules/md5module.c

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2026-03-06 22:24:20 +00:00
Miss Islington (bot) dbeb29aee3 [3.13] gh-142781: Fix type confusion in zoneinfo weak cache (GH-142925) (GH-145418)
(cherry picked from commit b611db491d)

Co-authored-by: zhong <60600792+superboy-zjc@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2026-03-03 12:47:57 +01:00
Miss Islington (bot) fb340275c4 [3.13] gh-143880: Fix data race in functools.partial in free threading build (GH-143882) (#145435)
Co-authored-by: Sam Gross <colesbury@gmail.com>
2026-03-02 21:31:46 +00:00
Miss Islington (bot) d305326458 [3.13] gh-145335: Fix crash when passing -1 as fd in os.pathconf (GH-145390) (#145432)
gh-145335: Fix crash when passing -1 as fd in os.pathconf (GH-145390)
(cherry picked from commit 5c3a47b94a)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2026-03-02 18:32:29 +00:00
Miss Islington (bot) cd3e9b3fd2 [3.13] gh-142787: Handle empty sqlite3 blob slices (GH-142824) (#145298)
(cherry picked from commit 06b0920f12)

Co-authored-by: A.Ibrahim <abdulrasheedibrahim47@gmail.com>
2026-02-27 01:13:08 +01:00
Stan Ulbrych e418e3351f [3.13] gh-88091: Fix unicodedata.decomposition() for Hangul Syllables (GH-144993) (GH-145190)
(cherry picked from commit 56c4f10d6e)
2026-02-25 00:27:40 +02:00
Miss Islington (bot) dd355045f6 [3.13] _struct.c: Fix UB from integer overflow in prepare_s (GH-145158) (#145163)
`_struct.c`: Fix UB from integer overflow in `prepare_s` (GH-145158)

Avoid possible undefined behaviour from signed overflow in `struct` module

As discovered via oss-fuzz.
(cherry picked from commit fd0400585e)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2026-02-24 01:16:45 +00:00
Bénédikt Tran 0038b58ac9 [3.13] gh-143698: correctly check scheduler and setpgroup values for os.posix_spawn[p] (GH-143699) (#145074)
* [3.13] gh-143698: correctly check `scheduler` and `setpgroup` values for `os.posix_spawn[p]` (GH-143699)

Fix an issue where passing invalid arguments to `os.posix_spawn[p]` functions
raised a SystemError instead of a TypeError, and allow to explicitly use `None`
for `scheduler` and `setpgroup` as specified in the docs.

(cherry picked from commit 347fc438cf)
2026-02-21 16:05:57 +01:00
Serhiy Storchaka e54507374b [3.13] gh-140652: Fix a crash in _interpchannels.list_all() after clo…sing a channel (GH-143743) (GH-144953)
(cherry picked from commit 3f50432e31)
2026-02-18 14:18:39 +00:00
Peter Bierma 9314ec23a6 [3.13] gh-144601: Avoid sharing exception objects raised in a PyInit function across multiple interpreters (GH-144602) (GH-144880)
(cherry picked from commit fd6b639a49)
2026-02-16 16:05:55 +00:00
Miss Islington (bot) ba0bab40f7 [3.13] gh-80667: Fix lookup for Tangut ideographs in unicodedata (GH-144789) (GH-144871) (GH-144875)
(cherry picked from commit 8b7b5a9946)
(cherry picked from commit bcabbd02f6)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Pierre Le Marre <dev@wismill.eu>
2026-02-16 15:02:01 +00:00
Miss Islington (bot) 37f818caef [3.13] gh-144833: Fix use-after-free in SSL module when SSL_new() fails (GH-144843) (#144859)
gh-144833: Fix use-after-free in SSL module when SSL_new() fails (GH-144843)

In newPySSLSocket(), when SSL_new() returns NULL, Py_DECREF(self)
was called before _setSSLError(get_state_ctx(self), ...), causing
a use-after-free. Additionally, get_state_ctx() was called with
self (PySSLSocket*) instead of sslctx (PySSLContext*), which is
a type confusion bug.

Fix by calling _setSSLError() before Py_DECREF() and using
sslctx instead of self for get_state_ctx().
(cherry picked from commit c91638ca06)

Co-authored-by: Ramin Farajpour Cami <ramin.blackhat@gmail.com>
2026-02-16 03:09:58 +00:00
Miss Islington (bot) 309bacdb4a [3.13] gh-143637: Fix re-entrant mutation of ancillary data in socket.sendmsg() (GH-143892) (#144785)
gh-143637: Fix re-entrant mutation of ancillary data in socket.sendmsg() (GH-143892)
(cherry picked from commit 82b92e3cd1)

Co-authored-by: Priyanshu Singh <priyanshu2282@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-02-13 15:58:59 +00:00
Serhiy Storchaka 2f354107f3 [3.13] gh-80667: Fix case-sensitivity of some Unicode literal escapes (GH-107281) (GH-144754)
Lookup for CJK ideograms and Hangul syllables is now case-insensitive,
as is the case for other character names.
(cherry picked from commit e66f4a5a9c)

Co-authored-by: James <snoopjedi@gmail.com>
2026-02-12 17:18:48 +00:00