]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-132909: handle overflow for `'K'` format in `do_mkvalue` (GH-132911) (...
authorBénédikt Tran <10796600+picnixz@users.noreply.github.com>
Fri, 25 Apr 2025 12:44:53 +0000 (14:44 +0200)
committerGitHub <noreply@github.com>
Fri, 25 Apr 2025 12:44:53 +0000 (12:44 +0000)
(cherry picked from commit 3fa024dec32e2ff86baf3dd7e14a0b314855327c)

Doc/c-api/arg.rst
Misc/NEWS.d/next/C API/2025-04-25-11-39-24.gh-issue-132909.JC3n_l.rst [new file with mode: 0644]
Python/modsupport.c

index 15402a4c48f56994aa126c06b2107ec6fb30844e..9420ae050814c509140fee87c67aec6c06dbd6b4 100644 (file)
@@ -639,6 +639,8 @@ Building values
    ``L`` (:class:`int`) [long long]
       Convert a C :c:expr:`long long` to a Python integer object.
 
+   .. _capi-py-buildvalue-format-K:
+
    ``K`` (:class:`int`) [unsigned long long]
       Convert a C :c:expr:`unsigned long long` to a Python integer object.
 
diff --git a/Misc/NEWS.d/next/C API/2025-04-25-11-39-24.gh-issue-132909.JC3n_l.rst b/Misc/NEWS.d/next/C API/2025-04-25-11-39-24.gh-issue-132909.JC3n_l.rst
new file mode 100644 (file)
index 0000000..81a37d0
--- /dev/null
@@ -0,0 +1,2 @@
+Fix an overflow when handling the :ref:`K <capi-py-buildvalue-format-K>` format
+in :c:func:`Py_BuildValue`. Patch by Bénédikt Tran.
index e9abf304e6502c6725f669b88651d3c79a98dbf9..cf4ab39f380358dea473e32385b7425d6a213c53 100644 (file)
@@ -320,7 +320,8 @@ do_mkvalue(const char **p_format, va_list *p_va)
             return PyLong_FromLongLong((long long)va_arg(*p_va, long long));
 
         case 'K':
-            return PyLong_FromUnsignedLongLong((long long)va_arg(*p_va, unsigned long long));
+            return PyLong_FromUnsignedLongLong(
+                va_arg(*p_va, unsigned long long));
 
         case 'u':
         {