Commits

Martin von Löwis committed ba17b21

Backport of r60743:
Patch #1736: Fix file name handling of _msi.FCICreate.

Comments (0)

Files changed (2)

 Extension Modules
 -----------------
 
+- Patch #1736: Fix file name handling of _msi.FCICreate.
+
 - Backport r59862 (issue #712900): make long regexp matches interruptable.
 
 - #1940: make it possible to use curses.filter() before curses.initscr()
 
 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))
     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);
     }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.