[Python-checkins] CVS: python/dist/src/Modules timemodule.c,2.85,2.86
Fred L. Drake
python-dev@python.org
2000年6月29日 14:31:05 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv26103/Modules
Modified Files:
timemodule.c
Log Message:
Trent Mick <trentm@activestate.com>:
This patch fixes a possible overflow in the Sleep system call on
Win32/64 in the time_sleep() function in the time module. For very
large values of the give time to sleep the number of milliseconds can
overflow and give unexpected sleep intervals. THis patch raises an
OverflowError if the value overflows.
Closes SourceForge patch #100514.
Index: timemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v
retrieving revision 2.85
retrieving revision 2.86
diff -C2 -r2.85 -r2.86
*** timemodule.c 2000年06月29日 20:56:28 2.85
--- timemodule.c 2000年06月29日 21:31:02 2.86
***************
*** 836,843 ****
#else /* !MSDOS */
#ifdef MS_WIN32
! /* XXX Can't interrupt this sleep */
! Py_BEGIN_ALLOW_THREADS
! Sleep((int)(secs*1000));
! Py_END_ALLOW_THREADS
#else /* !MS_WIN32 */
#ifdef PYOS_OS2
--- 836,850 ----
#else /* !MSDOS */
#ifdef MS_WIN32
! {
! double millisecs = secs * 1000.0;
! if (millisecs > (double)ULONG_MAX) {
! PyErr_SetString(PyExc_OverflowError, "sleep length is too large");
! return -1;
! }
! /* XXX Can't interrupt this sleep */
! Py_BEGIN_ALLOW_THREADS
! Sleep((unsigned long)millisecs);
! Py_END_ALLOW_THREADS
! }
#else /* !MS_WIN32 */
#ifdef PYOS_OS2