summaryrefslogtreecommitdiffstats
path: root/PC/_msi.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-02-12 13:47:26 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2008-02-12 13:47:26 (GMT)
commite0d30ef0cab80e7584ac3264985746812ccd6b0d (patch)
tree458b9a6f9a88fc1d968a7573401b6421eef5d495 /PC/_msi.c
parent116f72fa5ceb864efcc47da2f8c437fd29c7e8b3 (diff)
downloadcpython-e0d30ef0cab80e7584ac3264985746812ccd6b0d.zip
cpython-e0d30ef0cab80e7584ac3264985746812ccd6b0d.tar.gz
cpython-e0d30ef0cab80e7584ac3264985746812ccd6b0d.tar.bz2
Patch #1736: Fix file name handling of _msi.FCICreate.
Diffstat (limited to 'PC/_msi.c')
-rw-r--r--PC/_msi.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/PC/_msi.c b/PC/_msi.c
index 7d60d08..dfbdf3b 100644
--- a/PC/_msi.c
+++ b/PC/_msi.c
@@ -180,12 +180,12 @@ static FNFCIGETOPENINFO(cb_getopeninfo)
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 @@ static PyObject* fcicreate(PyObject* obj, PyObject* args)
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);
}