]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-136053: Check error for TYPE_SLICE in marshal.c (GH-136054)
authorAkshat Gupta <akshat.gupta24@gmail.com>
Sun, 29 Jun 2025 07:07:24 +0000 (12:37 +0530)
committerGitHub <noreply@github.com>
Sun, 29 Jun 2025 07:07:24 +0000 (10:07 +0300)
Fix a possible crash when deserializing a large marshal data
(at least several GiBs) containing a slice.

Misc/NEWS.d/next/Security/2025-06-27-21-23-19.gh-issue-136053.QZxcee.rst [new file with mode: 0644]
Python/marshal.c

diff --git a/Misc/NEWS.d/next/Security/2025-06-27-21-23-19.gh-issue-136053.QZxcee.rst b/Misc/NEWS.d/next/Security/2025-06-27-21-23-19.gh-issue-136053.QZxcee.rst
new file mode 100644 (file)
index 0000000..93caed3
--- /dev/null
@@ -0,0 +1 @@
+:mod:`marshal`: fix a possible crash when deserializing :class:`slice` objects.
index afbef6ee6796d9ac5c060cfd8d4f9dc4765957dd..15dd25d6268df42bfea49a7b7c31b1df198ef16e 100644 (file)
@@ -1656,6 +1656,9 @@ r_object(RFILE *p)
     case TYPE_SLICE:
     {
         Py_ssize_t idx = r_ref_reserve(flag, p);
+        if (idx < 0) {
+            break;
+        }
         PyObject *stop = NULL;
         PyObject *step = NULL;
         PyObject *start = r_object(p);