summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-04-17 20:06:44 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-04-17 20:06:44 (GMT)
commitcf8a1e51ece7cad7096963927993ddfa738627e6 (patch)
tree236620316415785822a0cd67eec0713d8d8409f2 /Modules/posixmodule.c
parentb38897fc91c7f4b80bc2025ade219674d7b78bf3 (diff)
downloadcpython-cf8a1e51ece7cad7096963927993ddfa738627e6.zip
cpython-cf8a1e51ece7cad7096963927993ddfa738627e6.tar.gz
cpython-cf8a1e51ece7cad7096963927993ddfa738627e6.tar.bz2
- Issue #17782: Fix undefined behaviour on platforms where ``struct timespec``'s "tv_nsec" member is not a C long.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 91352d4..551af2f 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -4775,6 +4775,8 @@ posix_utime(PyObject *self, PyObject *args, PyObject *kwargs)
}
if (times && (times != Py_None)) {
+ time_t a_sec, m_sec;
+ long a_nsec, m_nsec;
if (!PyTuple_CheckExact(times) || (PyTuple_Size(times) != 2)) {
PyErr_SetString(PyExc_TypeError,
"utime: 'times' must be either"
@@ -4783,11 +4785,15 @@ posix_utime(PyObject *self, PyObject *args, PyObject *kwargs)
}
utime.now = 0;
if (_PyTime_ObjectToTimespec(PyTuple_GET_ITEM(times, 0),
- &utime.atime_s, &utime.atime_ns) == -1 ||
+ &a_sec, &a_nsec) == -1 ||
_PyTime_ObjectToTimespec(PyTuple_GET_ITEM(times, 1),
- &utime.mtime_s, &utime.mtime_ns) == -1) {
+ &m_sec, &m_nsec) == -1) {
goto exit;
}
+ utime.atime_s = a_sec;
+ utime.atime_ns = a_nsec;
+ utime.mtime_s = m_sec;
+ utime.mtime_ns = m_nsec;
}
else if (ns) {
if (!PyTuple_CheckExact(ns) || (PyTuple_Size(ns) != 2)) {