[Python-checkins] cpython: Issue 24244: Prevents termination when an invalid format string is encountered
steve.dower
python-checkins at python.org
Sat May 23 00:08:56 CEST 2015
https://hg.python.org/cpython/rev/254b8e68959e
changeset: 96214:254b8e68959e
user: Steve Dower <steve.dower at microsoft.com>
date: Fri May 22 15:08:34 2015 -0700
summary:
Issue 24244: Prevents termination when an invalid format string is encountered on Windows.
files:
Misc/NEWS | 3 +++
Modules/timemodule.c | 9 ++-------
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -58,6 +58,9 @@
Library
-------
+- Issue 24244: Prevents termination when an invalid format string is
+ encountered on Windows in strftime.
+
- Issue #23973: PEP 484: Add the typing module.
- Issue #20035: Replaced the ``tkinter._fix`` module used for setting up the
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -616,13 +616,6 @@
{
if (outbuf[1]=='#')
++outbuf; /* not documented by python, */
- if (outbuf[1]=='\0' ||
- !strchr("aAbBcdHIjmMpSUwWxXyYzZ%", outbuf[1]))
- {
- PyErr_SetString(PyExc_ValueError, "Invalid format string");
- Py_DECREF(format);
- return NULL;
- }
if ((outbuf[1] == 'y') && buf.tm_year < 0)
{
PyErr_SetString(PyExc_ValueError,
@@ -660,7 +653,9 @@
PyErr_NoMemory();
break;
}
+ _Py_BEGIN_SUPPRESS_IPH
buflen = format_time(outbuf, i, fmt, &buf);
+ _Py_END_SUPPRESS_IPH
#if defined _MSC_VER && _MSC_VER >= 1400 && defined(__STDC_SECURE_LIB__)
err = errno;
#endif
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list