[Python-checkins] r60743 - in python/trunk: Misc/NEWS PC/_msi.c

martin.v.loewis python-checkins at python.org
Tue Feb 12 14:47:26 CET 2008


Author: martin.v.loewis
Date: Tue Feb 12 14:47:26 2008
New Revision: 60743

Modified:
   python/trunk/Misc/NEWS
   python/trunk/PC/_msi.c
Log:
Patch #1736: Fix file name handling of _msi.FCICreate.


Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Tue Feb 12 14:47:26 2008
@@ -1129,6 +1129,8 @@
 Extension Modules
 -----------------
 
+- Patch #1736: Fix file name handling of _msi.FCICreate.
+
 - Updated ``big5hkscs`` codec to the HKSCS revision of 2004.
 
 - #1940: make it possible to use curses.filter() before curses.initscr()

Modified: python/trunk/PC/_msi.c
==============================================================================
--- python/trunk/PC/_msi.c	(original)
+++ python/trunk/PC/_msi.c	Tue Feb 12 14:47:26 2008
@@ -180,12 +180,12 @@
 
 static PyObject* fcicreate(PyObject* obj, PyObject* args)
 {
-    char *cabname;
+    char *cabname, *p;
     PyObject *files;
     CCAB ccab;
     HFCI hfci;
     ERF erf;
-    int i;
+    Py_ssize_t i;
 
 
     if (!PyArg_ParseTuple(args, "sO:FCICreate", &cabname, &files))
@@ -208,22 +208,22 @@
     ccab.setID = 0;
     ccab.szDisk[0] = '\0';
 
-    for (i=0; cabname[i]; i++)
-	if (cabname[i] == '\\' || cabname[i] == '/')
-	    break;
+    for (i = 0, p = cabname; *p; p = CharNext(p))
+	if (*p == '\\' || *p == '/')
+	    i = p - cabname + 1;
 
-    if (i > sizeof(ccab.szCabPath) ||
-	strlen(cabname+i) > sizeof(ccab.szCab)) {
+    if (i >= sizeof(ccab.szCabPath) ||
+	strlen(cabname+i) >= sizeof(ccab.szCab)) {
 	PyErr_SetString(PyExc_ValueError, "path name too long");
 	return 0;
     }
 
-    if (cabname[i]) {
+    if (i > 0) {
 	memcpy(ccab.szCabPath, cabname, i);
 	ccab.szCabPath[i] = '\0';
 	strcpy(ccab.szCab, cabname+i);
     } else {
-	strcpy(ccab.szCabPath, ".");
+	strcpy(ccab.szCabPath, ".\\");
 	strcpy(ccab.szCab, cabname);
     }
 


More information about the Python-checkins mailing list