diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2008-06-11 07:41:16 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2008-06-11 07:41:16 (GMT) |
commit | 9d53457e599623fbad90833c3448835b42d7e7f9 (patch) | |
tree | 41d37b556618eb8e831463c576d854063a33d77b /Modules/datetimemodule.c | |
parent | 73baefd7fc86a7f8336e4142efcec74c201acf8f (diff) | |
download | cpython-9d53457e599623fbad90833c3448835b42d7e7f9.zip cpython-9d53457e599623fbad90833c3448835b42d7e7f9.tar.gz cpython-9d53457e599623fbad90833c3448835b42d7e7f9.tar.bz2 |
Merge in release25-maint r60793:
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 'Modules/datetimemodule.c')
-rw-r--r-- | Modules/datetimemodule.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c index 3443b42..fcbd2e9 100644 --- a/Modules/datetimemodule.c +++ b/Modules/datetimemodule.c @@ -1115,6 +1115,8 @@ format_utcoffset(char *buf, size_t buflen, const char *sep, char sign; int none; + assert(buflen >= 1); + offset = call_utcoffset(tzinfo, tzinfoarg, &none); if (offset == -1 && PyErr_Occurred()) return -1; @@ -1206,6 +1208,11 @@ wrap_strftime(PyObject *object, const char *format, size_t format_len, * a new format. Since computing the replacements for those codes * is expensive, don't unless they're actually used. */ + if (format_len > INT_MAX - 1) { + PyErr_NoMemory(); + goto Done; + } + totalnew = format_len + 1; /* realistic if no %z/%Z/%f */ newfmt = PyString_FromStringAndSize(NULL, totalnew); if (newfmt == NULL) goto Done; |