From 7bca4bafad70caf0edeb062195fbf9be60e1d6f7 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Wed, 20 Mar 2019 20:10:02 +0900 Subject: [PATCH 1/2] bpo-8677: use PY_DWORD_MAX instead of INT_MAX --- PC/winreg.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/PC/winreg.c b/PC/winreg.c index 4dc4e0c281bd892..0c9947a9b708414 100644 --- a/PC/winreg.c +++ b/PC/winreg.c @@ -1605,13 +1605,11 @@ winreg_SetValue_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, long rc; if (type != REG_SZ) { - PyErr_SetString(PyExc_TypeError, - "Type must be winreg.REG_SZ"); + PyErr_SetString(PyExc_TypeError, "type must be winreg.REG_SZ"); return NULL; } - if (value_length >= INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "the value is too long"); + if (value_length >= PY_DWORD_MAX) { + PyErr_SetString(PyExc_OverflowError, "value is too long"); return NULL; } From c2abed9b5decf298ff1176bdc174e2a17620b29d Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 20 Mar 2019 20:17:49 +0900 Subject: [PATCH 2/2] Update PC/winreg.c Co-Authored-By: methane --- PC/winreg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PC/winreg.c b/PC/winreg.c index 0c9947a9b708414..ae0c292b7172e9a 100644 --- a/PC/winreg.c +++ b/PC/winreg.c @@ -1608,7 +1608,7 @@ winreg_SetValue_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, PyErr_SetString(PyExc_TypeError, "type must be winreg.REG_SZ"); return NULL; } - if (value_length >= PY_DWORD_MAX) { + if ((size_t)value_length >= PY_DWORD_MAX) { PyErr_SetString(PyExc_OverflowError, "value is too long"); return NULL; }