]> granicus.if.org Git - python/commitdiff
bpo-8677: use PY_SSIZE_T_CLEAN in PC/winreg.c (GH-12466)
authorInada Naoki <songofacandy@gmail.com>
Wed, 20 Mar 2019 10:10:17 +0000 (19:10 +0900)
committerGitHub <noreply@github.com>
Wed, 20 Mar 2019 10:10:17 +0000 (19:10 +0900)
PC/winreg.c

index 3a6ea3689fd12a09739be06dae89b2d480fa4b99..4dc4e0c281bd892253143952498287da0eb8123c 100644 (file)
@@ -12,6 +12,7 @@
 
 */
 
+#define PY_SSIZE_T_CLEAN
 #include "Python.h"
 #include "structmember.h"
 #include "windows.h"
@@ -1608,6 +1609,11 @@ winreg_SetValue_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key,
                         "Type must be winreg.REG_SZ");
         return NULL;
     }
+    if (value_length >= INT_MAX) {
+        PyErr_SetString(PyExc_OverflowError,
+                        "the value is too long");
+        return NULL;
+    }
 
     Py_BEGIN_ALLOW_THREADS
     rc = RegSetValueW(key, sub_key, REG_SZ, value, value_length+1);