[Python-checkins] r71153 - in python/branches/release26-maint: Misc/NEWS Python/pythonrun.c

matthias.klose python-checkins at python.org
Sat Apr 4 16:19:57 CEST 2009


Author: matthias.klose
Date: Sat Apr  4 16:19:56 2009
New Revision: 71153

Log:
Merged revisions 71152 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r71152 | matthias.klose | 2009-04-04 16:18:13 +0200 (Sa, 04 Apr 2009) | 3 lines
  
  - Issue #3845: In PyRun_SimpleFileExFlags avoid invalid memory access with
    short file names.
........


Modified:
   python/branches/release26-maint/   (props changed)
   python/branches/release26-maint/Misc/NEWS
   python/branches/release26-maint/Python/pythonrun.c

Modified: python/branches/release26-maint/Misc/NEWS
==============================================================================
--- python/branches/release26-maint/Misc/NEWS	(original)
+++ python/branches/release26-maint/Misc/NEWS	Sat Apr  4 16:19:56 2009
@@ -89,6 +89,9 @@
 - Issue #4509: Various issues surrounding resize of bytearray objects to
   which there are buffer exports.
 
+- Issue #3845: In PyRun_SimpleFileExFlags avoid invalid memory access with
+  short file names.
+
 Library
 -------
 

Modified: python/branches/release26-maint/Python/pythonrun.c
==============================================================================
--- python/branches/release26-maint/Python/pythonrun.c	(original)
+++ python/branches/release26-maint/Python/pythonrun.c	Sat Apr  4 16:19:56 2009
@@ -895,7 +895,7 @@
 {
 	PyObject *m, *d, *v;
 	const char *ext;
-	int set_file_name = 0, ret;
+	int set_file_name = 0, ret, len;
 
 	m = PyImport_AddModule("__main__");
 	if (m == NULL)
@@ -912,7 +912,8 @@
 		set_file_name = 1;
 		Py_DECREF(f);
 	}
-	ext = filename + strlen(filename) - 4;
+	len = strlen(filename);
+	ext = filename + len - (len > 4 ? 4 : 0);
 	if (maybe_pyc_file(fp, filename, ext, closeit)) {
 		/* Try to run a pyc file. First, re-open in binary */
 		if (closeit)


More information about the Python-checkins mailing list