Patch #1736: Fix file name handling of _msi.FCICreate.
This commit is contained in:
parent
116f72fa5c
commit
e0d30ef0ca
|
@ -1129,6 +1129,8 @@ Library
|
||||||
Extension Modules
|
Extension Modules
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Patch #1736: Fix file name handling of _msi.FCICreate.
|
||||||
|
|
||||||
- Updated ``big5hkscs`` codec to the HKSCS revision of 2004.
|
- Updated ``big5hkscs`` codec to the HKSCS revision of 2004.
|
||||||
|
|
||||||
- #1940: make it possible to use curses.filter() before curses.initscr()
|
- #1940: make it possible to use curses.filter() before curses.initscr()
|
||||||
|
|
18
PC/_msi.c
18
PC/_msi.c
|
@ -180,12 +180,12 @@ static FNFCIGETOPENINFO(cb_getopeninfo)
|
||||||
|
|
||||||
static PyObject* fcicreate(PyObject* obj, PyObject* args)
|
static PyObject* fcicreate(PyObject* obj, PyObject* args)
|
||||||
{
|
{
|
||||||
char *cabname;
|
char *cabname, *p;
|
||||||
PyObject *files;
|
PyObject *files;
|
||||||
CCAB ccab;
|
CCAB ccab;
|
||||||
HFCI hfci;
|
HFCI hfci;
|
||||||
ERF erf;
|
ERF erf;
|
||||||
int i;
|
Py_ssize_t i;
|
||||||
|
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "sO:FCICreate", &cabname, &files))
|
if (!PyArg_ParseTuple(args, "sO:FCICreate", &cabname, &files))
|
||||||
|
@ -208,22 +208,22 @@ static PyObject* fcicreate(PyObject* obj, PyObject* args)
|
||||||
ccab.setID = 0;
|
ccab.setID = 0;
|
||||||
ccab.szDisk[0] = '\0';
|
ccab.szDisk[0] = '\0';
|
||||||
|
|
||||||
for (i=0; cabname[i]; i++)
|
for (i = 0, p = cabname; *p; p = CharNext(p))
|
||||||
if (cabname[i] == '\\' || cabname[i] == '/')
|
if (*p == '\\' || *p == '/')
|
||||||
break;
|
i = p - cabname + 1;
|
||||||
|
|
||||||
if (i > sizeof(ccab.szCabPath) ||
|
if (i >= sizeof(ccab.szCabPath) ||
|
||||||
strlen(cabname+i) > sizeof(ccab.szCab)) {
|
strlen(cabname+i) >= sizeof(ccab.szCab)) {
|
||||||
PyErr_SetString(PyExc_ValueError, "path name too long");
|
PyErr_SetString(PyExc_ValueError, "path name too long");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cabname[i]) {
|
if (i > 0) {
|
||||||
memcpy(ccab.szCabPath, cabname, i);
|
memcpy(ccab.szCabPath, cabname, i);
|
||||||
ccab.szCabPath[i] = '\0';
|
ccab.szCabPath[i] = '\0';
|
||||||
strcpy(ccab.szCab, cabname+i);
|
strcpy(ccab.szCab, cabname+i);
|
||||||
} else {
|
} else {
|
||||||
strcpy(ccab.szCabPath, ".");
|
strcpy(ccab.szCabPath, ".\\");
|
||||||
strcpy(ccab.szCab, cabname);
|
strcpy(ccab.szCab, cabname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue