Issue 24244: Prevents termination when an invalid format string is encountered on Windows.

This commit is contained in:
Steve Dower 2015-05-22 15:08:34 -07:00
parent 945fff44c4
commit d9ef74e3dd
2 changed files with 5 additions and 7 deletions

View File

@ -58,6 +58,9 @@ Core and Builtins
Library 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 #23973: PEP 484: Add the typing module.
- Issue #20035: Replaced the ``tkinter._fix`` module used for setting up the - Issue #20035: Replaced the ``tkinter._fix`` module used for setting up the

View File

@ -616,13 +616,6 @@ time_strftime(PyObject *self, PyObject *args)
{ {
if (outbuf[1]=='#') if (outbuf[1]=='#')
++outbuf; /* not documented by python, */ ++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) if ((outbuf[1] == 'y') && buf.tm_year < 0)
{ {
PyErr_SetString(PyExc_ValueError, PyErr_SetString(PyExc_ValueError,
@ -660,7 +653,9 @@ time_strftime(PyObject *self, PyObject *args)
PyErr_NoMemory(); PyErr_NoMemory();
break; break;
} }
_Py_BEGIN_SUPPRESS_IPH
buflen = format_time(outbuf, i, fmt, &buf); buflen = format_time(outbuf, i, fmt, &buf);
_Py_END_SUPPRESS_IPH
#if defined _MSC_VER && _MSC_VER >= 1400 && defined(__STDC_SECURE_LIB__) #if defined _MSC_VER && _MSC_VER >= 1400 && defined(__STDC_SECURE_LIB__)
err = errno; err = errno;
#endif #endif