summaryrefslogtreecommitdiffstats
path: root/Modules/datetimemodule.c
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-06-18 00:47:36 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-06-18 00:47:36 (GMT)
commit9c74b14fe9b6dddc9d41dd37f431f174350004d4 (patch)
tree3d30d794259f55f5021f5e8036447523d0e1eea3 /Modules/datetimemodule.c
parent036aa5433e963f6576c5dfa02ace4ca0e2c642a2 (diff)
downloadcpython-9c74b14fe9b6dddc9d41dd37f431f174350004d4.zip
cpython-9c74b14fe9b6dddc9d41dd37f431f174350004d4.tar.gz
cpython-9c74b14fe9b6dddc9d41dd37f431f174350004d4.tar.bz2
Merged revisions 64114 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r64114 | gregory.p.smith | 2008-06-11 09:41:16 +0200 (mer., 11 juin 2008) | 6 lines 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.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c
index 6c2d5a0..4dd4fe31 100644
--- a/Modules/datetimemodule.c
+++ b/Modules/datetimemodule.c
@@ -1111,6 +1111,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;
@@ -1250,6 +1252,11 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
* a new format. Since computing the replacements for those codes
* is expensive, don't unless they're actually used.
*/
+ if (flen > INT_MAX - 1) {
+ PyErr_NoMemory();
+ goto Done;
+ }
+
totalnew = flen + 1; /* realistic if no %z/%Z */
newfmt = PyBytes_FromStringAndSize(NULL, totalnew);
if (newfmt == NULL) goto Done;