summaryrefslogtreecommitdiff
path: root/Python/ast.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-02-14 11:26:18 +0000
committerMartin v. Löwis <martin@v.loewis.de>2008-02-14 11:26:18 +0000
commit73c01d410117a573731e6c2afc9694005f8d11aa (patch)
treec0cb9e868b2cb57d9ebd5685d0054b551a33e889 /Python/ast.c
parentabcb59a1d87c6121db913ce56c9f91fd43f33916 (diff)
downloadcpython-git-73c01d410117a573731e6c2afc9694005f8d11aa.tar.gz
Added checks for integer overflows, contributed by Google. Some are
only available if asserts are left in the code, in cases where they can't be triggered from Python code.
Diffstat (limited to 'Python/ast.c')
-rw-r--r--Python/ast.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 2c03ad6acf..3381260d07 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -3130,6 +3130,9 @@ decode_unicode(const char *s, size_t len, int rawmode, const char *encoding)
buf = (char *)s;
u = NULL;
} else {
+ /* check for integer overflow */
+ if (len > PY_SIZE_MAX / 4)
+ return NULL;
/* "\XX" may become "\u005c\uHHLL" (12 bytes) */
u = PyString_FromStringAndSize((char *)NULL, len * 4);
if (u == NULL)