diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2008-02-14 11:26:18 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2008-02-14 11:26:18 (GMT) |
commit | 73c01d410117a573731e6c2afc9694005f8d11aa (patch) | |
tree | c0cb9e868b2cb57d9ebd5685d0054b551a33e889 /Python/ast.c | |
parent | abcb59a1d87c6121db913ce56c9f91fd43f33916 (diff) | |
download | cpython-73c01d410117a573731e6c2afc9694005f8d11aa.zip cpython-73c01d410117a573731e6c2afc9694005f8d11aa.tar.gz cpython-73c01d410117a573731e6c2afc9694005f8d11aa.tar.bz2 |
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.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Python/ast.c b/Python/ast.c index 2c03ad6..3381260 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) |