Commit b027c6ca authored by Benjamin Peterson's avatar Benjamin Peterson

fix possible overflow bugs in unicodedata (closes #23367)

parent b198ad9a
...@@ -50,6 +50,8 @@ Library ...@@ -50,6 +50,8 @@ Library
posixpath.expandvars(). Fixed all os.path implementations on posixpath.expandvars(). Fixed all os.path implementations on
unicode-disabled builds. unicode-disabled builds.
- Issue #23367: Fix possible overflows in the unicodedata module.
- Issue #23363: Fix possible overflow in itertools.permutations. - Issue #23363: Fix possible overflow in itertools.permutations.
- Issue #23364: Fix possible overflow in itertools.product. - Issue #23364: Fix possible overflow in itertools.product.
......
...@@ -506,8 +506,15 @@ nfd_nfkd(PyObject *self, PyObject *input, int k) ...@@ -506,8 +506,15 @@ nfd_nfkd(PyObject *self, PyObject *input, int k)
stackptr = 0; stackptr = 0;
isize = PyUnicode_GET_SIZE(input); isize = PyUnicode_GET_SIZE(input);
space = isize;
/* Overallocate at most 10 characters. */ /* Overallocate at most 10 characters. */
space = (isize > 10 ? 10 : isize) + isize; if (space > 10) {
if (space <= PY_SSIZE_T_MAX - 10)
space += 10;
}
else {
space *= 2;
}
result = PyUnicode_FromUnicode(NULL, space); result = PyUnicode_FromUnicode(NULL, space);
if (!result) if (!result)
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment