15291 Commits

Author SHA1 Message Date
Pablo Galindo Salgado 316f6265b7 [3.14] gh-148178: Validate remote debug offset tables on load (GH-148187) (#148577)
Treat the debug offset tables read from a target process as untrusted input
and validate them before the unwinder uses any reported sizes or offsets.

Add a shared validator in debug_offsets_validation.h and run it once when
_Py_DebugOffsets is loaded and once when AsyncioDebug is loaded. The checks
cover section sizes used for fixed local buffers and every offset that is
later dereferenced against a local buffer or local object view. This keeps
the bounds checks out of the sampling hot path while rejecting malformed
tables up front.
(cherry picked from commit 289fd2c97a)
2026-05-04 22:43:43 +01:00
Miss Islington (bot) 3e25cd9619 [3.14] gh-148093: Raise binascii.Error from binascii.a2b_uu() on empty input (GH-149077) (GH-149350)
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:10:47 +00:00
Zachary Ware 6297185237 [3.14] gh-149254: Update CI to use latest OpenSSL versions (GH-149333)
Also update Modules/_ssl_data_35.h to include an added symbol from 3.5.6.

(adapted from commit 68fe899feb)
2026-05-03 21:11:42 +00:00
Miss Islington (bot) 5ec845a044 [3.14] gh-148967: Fix FFI type pointer handling for C complex support in set_stginfo_ffi_type_pointer (GH-148969) (GH-149224)
(cherry picked from commit f2c7c0d2b7)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2026-05-01 15:43:38 +02:00
Sergey Miryanov 4d0ae4cba9 [3.14] GH-148726: Add heap_size to _gc_runtime_state (#149025) 2026-04-29 13:04:11 +03:00
Stan Ulbrych c181c5fa16 [3.14] gh-149017: Upgrade bundled Expat to 2.8.0 (GH-149020) (#149073)
(cherry picked from commit 005555a3f0)
2026-04-28 16:30:12 +03:00
Miss Islington (bot) 22d53a9141 [3.14] gh-148529: Minor improvements of the struct module documentation (GH-148565) (GH-149063)
* 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)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-04-27 23:07:00 +03:00
Sergey Miryanov 9a7e205e46 [3.14] GH-148726: Forward-port generational GC (#148720)
Co-authored-by: Neil Schemenauer <nas@arctrix.com>
Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
2026-04-26 21:12:52 +03:00
Miss Islington (bot) 8acb98a1c2 [3.14] gh-148973: fix segfault on mismatch between consts size and oparg in compiler (GH-148974) (#148980)
gh-148973: fix segfault on mismatch between consts size and oparg in compiler (GH-148974)
(cherry picked from commit c650b51c32)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2026-04-25 13:53:42 +01:00
Miss Islington (bot) 89f44ac422 [3.14] gh-148735: Fix a UAF in Element.findtext() (GH-148738) (#148916)
(cherry picked from commit 0469e6d38d)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-24 21:38:15 +01:00
Miss Islington (bot) 0f656e2641 [3.14] gh-148484: Fix memory leak of iterator in array.array constructor (GH-148523) (GH-148678)
(cherry picked from commit afde75664e)

Co-authored-by: Gleb Popov <gvpopov.dev@gmail.com>
2026-04-23 16:00:37 +02:00
Miss Islington (bot) 5e758ff525 [3.14] gh-148464: Add missing `__ctype_le/be__` attributes for complex types in the ctype module (GH-148485) (GH-148677)
(cherry picked from commit 769cc8338f)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2026-04-23 15:57:55 +02:00
Stan Ulbrych 5f1b710a28 [3.14] gh-148801: Fix unbound C recursion in Element.__deepcopy__() (GH-148802) (#148842)
(cherry picked from commit 33e82be174)
2026-04-22 22:19:25 +01:00
Miss Islington (bot) 5aa8234cce [3.14] gh-146578: _zstd: Fix printf format for pledged size errors (GH-146576) (#148855)
gh-146578: _zstd: Fix printf format for pledged size errors (GH-146576)

Use %llu instead of %ull for unsigned long long in zstd_contentsize_converter ValueError messages.
(cherry picked from commit 09233bd198)

Co-authored-by: cui <cuiweixie@gmail.com>
2026-04-21 13:31:46 -07:00
Miss Islington (bot) 27522b7d6e [3.14] gh-148808: Add boundary check to asyncio.AbstractEventLoop.sock_recvf… (GH-148809) (#148837)
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:19 +05:30
Miss Islington (bot) 7f6a0c377b [3.14] gh-148651: Fix refcount leak in _zstd decompressor options (GH-148657) (#148691)
gh-148651: Fix refcount leak in _zstd decompressor options (GH-148657)

The option parsing in Modules/_zstd/decompressor.c had a missing Py_DECREF(value) before the early return -1 when PyLong_AsInt(key) fails. The identical code in Modules/_zstd/compressor.c line 158 has the fix.
(cherry picked from commit 446edda209)

Co-authored-by: Michael Bommarito <michael.bommarito@gmail.com>
2026-04-17 16:07:54 +00:00
Miss Islington (bot) 6a5f79c8d7 [3.14] gh-148395: Fix a possible UAF in {LZMA,BZ2,_Zlib}Decompressor (GH-148396) (#148480)
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:40:54 +00:00
Miss Islington (bot) 4f8a77bf3f [3.14] gh-145105: Fix crash in csv.reader with re-entrant iterator (GH-145106) (#148404)
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:46:26 +00:00
Miss Islington (bot) bb78ec8fa8 [3.14] gh-148274: properly handle result from PyObject_VisitManagedDict (GH-148275) (#148295)
gh-148274: properly handle result from `PyObject_VisitManagedDict` (GH-148275)
(cherry picked from commit ee2775cfae)

Co-authored-by: Max Bachmann <kontakt@maxbachmann.de>
2026-04-09 13:49:09 +00:00
Miss Islington (bot) 07158b605d [3.14] gh-146613: Fix re-entrant use-after-free in itertools._grouper (GH-147962) (#148010)
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-06 18:23:08 +03:00
Miss Islington (bot) 64207c930b [3.14] gh-145883: Fix two heap-buffer-overflows in _zoneinfo (GH-145885) (#148087)
(cherry picked from commit fe9befc1ca)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-04 17:13:13 +01:00
sunmy2019 b406d85603 [3.14] gh-146615: Fix format specifiers in extension modules (GH-146617) (#147704)
Fix format specifier in parse_task_name() for long result.
2026-04-01 15:12:44 +02:00
Miss Islington (bot) 25b48b84b8 [3.14] gh-143050: Correct PyLong_FromString() to use _PyLong_Negate() (GH-145901) (#147331)
gh-143050: Correct PyLong_FromString() to use _PyLong_Negate() (GH-145901)

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().
(cherry picked from commit db5936c5b8)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-31 16:14:12 +02:00
Serhiy Storchaka 58c7259133 [3.14] gh-146615: Fix format specifiers in extension modules (GH-146617) (GH-146652)
(cherry picked from commit 1c396e1821)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2026-03-31 10:07:09 +00:00
Miss Islington (bot) 3866c2947b [3.14] gh-146615: Fix format specifiers in test cextensions (GH-146618) (GH-146649)
(cherry picked from commit b7055533ab)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2026-03-31 08:31:05 +00:00
Miss Islington (bot) de234fc07a [3.14] gh-146579: _zstd: Fix decompression options dict error message (GH-146577) (#146611)
The TypeError in _zstd_set_d_parameters incorrectly referred to
compression options; say decompression options instead.
(cherry picked from commit 4d0e8ee649)

Co-authored-by: cui <cuiweixie@gmail.com>
2026-03-30 08:26:45 +00:00
Miss Islington (bot) 36c22d06f0 [3.14] gh-146083: Upgrade bundled Expat to 2.7.5 (GH-146085) (#146603)
(cherry picked from commit e39d84a37d)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2026-03-29 17:31:02 +00:00
Miss Islington (bot) 1458ea0065 [3.14] gh-146090: fix memory management of internal sqlite3 callback contexts (GH-146569) (#146595)
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:15:05 +02:00
Bénédikt Tran 883b6d22d1 [3.14] gh-146080: fix a crash in SNI callbacks when the SSL object is gone (GH-146573) (#146597)
(cherry picked from commit 24db78c532)
2026-03-29 12:58:37 +00:00
Miss Islington (bot) d7e04e7b8d [3.14] gh-146480: Override the exception in _PyErr_SetKeyError() (GH-146486) (#146511)
gh-146480: Override the exception in _PyErr_SetKeyError() (GH-146486)

If _PyErr_SetKeyError() is called with an exception set, it now
replaces the current exception with KeyError (as expected), instead
of setting a SystemError or failing with a fatal error (in debug
mode).
(cherry picked from commit d4153a9f76)

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-27 11:48:29 +00:00
Miss Islington (bot) de54353235 [3.14] gh-144837: Improve documentation for more collection methods (GH-144841) (GH-146483)
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:55:25 +00:00
Miss Islington (bot) e8c3d31b2c [3.14] gh-146059: Call fast_save_leave() in pickle save_frozenset() (GH-146173) (#146473)
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-26 17:02:20 +00:00
Miss Islington (bot) 8a25840a2a [3.14] gh-145633: Fix struct.pack('f') on s390x (GH-146422) (#146460)
gh-145633: Fix struct.pack('f') on s390x (GH-146422)

Use PyFloat_Pack4() to raise OverflowError.
Add more tests on packing/unpacking floats.
(cherry picked from commit 8de70b31c5)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2026-03-26 11:38:42 +00:00
Pablo Galindo Salgado 58c5eda24c [3.14] gh-146308: Fix error handling issues in _remote_debugging module (GH-146309) (#146398)
(cherry picked from commit ae6adc9079)
2026-03-25 01:05:47 +00:00
Miss Islington (bot) cbb1985b72 [3.14] GH-131296: Suppress clang-cl warnings in socketmodule.c (GH-131821) (GH-146339)
(cherry picked from commit cc8e6d2703)

Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
2026-03-24 00:27:20 +01:00
Miss Islington (bot) c334bdee7b [3.14] GH-131296: Fix clang-cl warning on Windows in socketmodule.h (GH-131832) (GH-146340)
(cherry picked from commit 59e2330cf3)

Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
2026-03-24 00:27:01 +01:00
Serhiy Storchaka e31c551216 [3.14] gh-145264: Do not ignore excess Base64 data after the first padded quad (GH-145267) (GH-146326)
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)
2026-03-24 00:20:26 +01:00
Miss Islington (bot) 69a37be21c [3.14] gh-146245: Fix reference and buffer leaks via audit hook in socket module (GH-146248) (GH-146274)
(cherry picked from commit c30fae4bea)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
2026-03-22 11:55:13 +00:00
AN Long 6bd5992d8b [3.14] gh-129849: Add tests for Py_tp_bases (GH-143208) (#146225)
(cherry picked from commit 6f8867a676)
2026-03-21 15:22:58 +05:30
Miss Islington (bot) a2a45d7d13 [3.14] gh-146092: Raise MemoryError on allocation failure in _zoneinfo (GH-146165) (#146223)
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:44:19 +00:00
Serhiy Storchaka 2105187546 [3.14] Improve tests for the PyUnicodeWriter C API (GH-146157) (GH-146180)
Add tests for corner cases: NULL pointers and out of range values.
(cherry picked from commit ab47892c32)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-03-20 11:44:25 +00:00
Miss Islington (bot) 5feedc7593 [3.14] gh-146093: Fix csv _set_str(): check if PyUnicode_DecodeASCII() failed (GH-146113) (#146130)
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:47:39 +00:00
Miss Islington (bot) 6980b94c3a [3.14] gh-146076: Fix crash when a ZoneInfo subclass is missing a _weak_cache (GH-146082) (GH-146116)
(cherry picked from commit 3b06d68d8a)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2026-03-18 15:23:46 +00:00
Serhiy Storchaka a005f323b7 [3.14] gh-144545: Improve handling of default values in Argument Clinic (GH-146016) (GH-146052)
* Add the c_init_default attribute which is used to initialize the C variable
  if the default is not explicitly provided.
* Add the c_default_init() method which is used to derive c_default from
  default if c_default is not explicitly provided.
* Explicit c_default and py_default are now almost always have precedence
  over the generated value.
* Add support for bytes literals as default values.
* Improve support for str literals as default values (support non-ASCII
  and non-printable characters and special characters like backslash or quotes).
* Fix support for str and bytes literals containing trigraphs, "/*" and "*/".
* Improve support for default values in converters "char" and "int(accept={str})".
* Converter "int(accept={str})" now requires 1-character string instead of
  integer as default value.
* Add support for non-None default values in converter "Py_buffer": NULL,
  str and bytes literals.
* Improve error handling for invalid default values.
* Rename Null to NullType for consistency.
(cherry picked from commit 99e2c5eccd)
2026-03-17 10:55:15 +00:00
Miss Islington (bot) 0548f41053 [3.14] gh-144984: Fix crash in Expat's ExternalEntityParserCreate error paths (GH-144992) (#146019)
gh-144984: Fix crash in Expat's `ExternalEntityParserCreate` error paths (GH-144992)
(cherry picked from commit e6b9a14069)

Co-authored-by: Ramin Farajpour Cami <ramin.blackhat@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-03-17 01:49:39 +01:00
Miss Islington (bot) a1f2fefc32 [3.14] gh-144986: Fix memory leak in atexit.register() (GH-144987) (#145020)
gh-144986: Fix memory leak in atexit.register() (GH-144987)
(cherry picked from commit 50c14719fb)

Co-authored-by: Shamil <ashm.tech@proton.me>
2026-03-16 13:56:05 +05:30
Miss Islington (bot) e0a8a6da90 [3.14] gh-145986: Avoid unbound C recursion in conv_content_model in pyexpat.c (CVE 2026-4224) (GH-145987) (#145995)
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>
2026-03-15 22:13:58 +00:00
Stan Ulbrych 87fac9b8ee [3.14] gh-145783: Propagate errors raised in NEW_TYPE_COMMENT (GH-145784) (#145926) 2026-03-13 18:08:04 +00:00
bkap123 485699216f [3.14] gh-145446: Add critical section in functools module for PyDict_Next (GH-145487) (GH-145879)
(cherry picked from commit 17eb0354ff)
2026-03-13 13:21:04 +01:00
Miss Islington (bot) 59be951e15 [3.14] gh-145492: Fix defaultdict __repr__ infinite recursion (GH-145659) (GH-145747)
(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:31 +01:00