summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2007-05-06 10:00:02 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2007-05-06 10:00:02 (GMT)
commita14c4bbbaa2a3c20e92edbd8fcf162a593474209 (patch)
tree1e636818118fbdface8b56977c79d40e26b6c9c8
parent9bc47120d370aa7f621013bcfa1e0b3f1b31505f (diff)
downloadcpython-a14c4bbbaa2a3c20e92edbd8fcf162a593474209.zip
cpython-a14c4bbbaa2a3c20e92edbd8fcf162a593474209.tar.gz
cpython-a14c4bbbaa2a3c20e92edbd8fcf162a593474209.tar.bz2
Check whether the strlen() result overflows Py_ssize_t.
-rw-r--r--Objects/unicodeobject.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index af98a90..9dc96da 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -396,7 +396,11 @@ PyObject *PyUnicode_FromUnicode(const Py_UNICODE *u,
PyObject *PyUnicode_FromString(const char *u)
{
PyUnicodeObject *unicode;
- Py_ssize_t size = strlen(u);
+ size_t size = strlen(u);
+ if (size > PY_SSIZE_T_MAX) {
+ PyErr_SetString(PyExc_OverflowError, "input too long");
+ return NULL;
+ }
/* If the Unicode data is known at construction time, we can apply
some optimizations which share commonly used objects. */