diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-06-23 17:12:14 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-06-23 17:12:14 (GMT) |
commit | 8eeae2126ca7dd91ae6f10443eda1af5338bccf7 (patch) | |
tree | 33ec8ddfbb4c5152de7d1645ef26691e77132596 /Objects/unicodeobject.c | |
parent | 36a7e4f74a7fdf193f0fd0fab8ace602bca490a5 (diff) | |
download | cpython-8eeae2126ca7dd91ae6f10443eda1af5338bccf7.zip cpython-8eeae2126ca7dd91ae6f10443eda1af5338bccf7.tar.gz cpython-8eeae2126ca7dd91ae6f10443eda1af5338bccf7.tar.bz2 |
Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise
OverflowError when an argument of %c format is out of range.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 1c48197..2e40c27 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -2489,8 +2489,13 @@ PyUnicode_FromFormatV(const char *format, va_list vargs) switch (*f) { case 'c': { - Py_UCS4 ordinal = va_arg(count, int); - maxchar = Py_MAX(maxchar, ordinal); + int ordinal = va_arg(count, int); + if (ordinal < 0 || ordinal > MAX_UNICODE) { + PyErr_SetString(PyExc_OverflowError, + "%c arg not in range(0x110000)"); + goto fail; + } + maxchar = Py_MAX(maxchar, (Py_UCS4)ordinal); n++; break; } |