summaryrefslogtreecommitdiffstats
path: root/Python/getmtime.c
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-06-30 16:18:57 (GMT)
committerFred Drake <fdrake@acm.org>2000-06-30 16:18:57 (GMT)
commit4c82b2366ff2eb38f062fc5da1b15ddd1c01fa4b (patch)
tree9706525a1647754a3d5aed1ba183b4544acaaebe /Python/getmtime.c
parent4358b2c928e756a77613da7cb8c57676e8872935 (diff)
downloadcpython-4c82b2366ff2eb38f062fc5da1b15ddd1c01fa4b.zip
cpython-4c82b2366ff2eb38f062fc5da1b15ddd1c01fa4b.tar.gz
cpython-4c82b2366ff2eb38f062fc5da1b15ddd1c01fa4b.tar.bz2
Trent Mick <trentm@activestate.com>:
This patch fixes possible overflow in the use of PyOS_GetLastModificationTime in getmtime.c and Python/import.c. Currently PyOS_GetLastModificationTime returns a C long. This can overflow on Win64 where sizeof(time_t) > sizeof(long). Besides it should logically return a time_t anyway (this patch changes this). As well, import.c uses PyOS_GetLastModificationTime for .pyc timestamping. There has been recent discussion about the .pyc header format on python-dev. This patch adds oveflow checking to import.c so that an exception will be raised if the modification time overflows. There are a few other minor 64-bit readiness changes made to the module as well: - size_t instead of int or long for function-local buffer and string length variables - one buffer overflow check was added (raises an exception on possible overflow, this overflow chance exists on 32-bit platforms as well), no other possible buffer overflows existed (from my analysis anyway) Closes SourceForge patch #100509.
Diffstat (limited to 'Python/getmtime.c')
-rw-r--r--Python/getmtime.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/getmtime.c b/Python/getmtime.c
index 4bf2adf..aea6909 100644
--- a/Python/getmtime.c
+++ b/Python/getmtime.c
@@ -33,13 +33,14 @@ PERFORMANCE OF THIS SOFTWARE.
/* (A separate file because this may be OS dependent) */
+#include "Python.h"
#include "config.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
-long
+time_t
PyOS_GetLastModificationTime(path, fp)
char *path;
FILE *fp;