bpo-1104: msilib.SummaryInfo.GetProperty() truncates the string by one character (GH-4517)

Add one char to MsiSummaryInfoGetProperty() output
Based on the patch in bpo-1104 by Anthony Tuininga (atuining) and Mark McMahon (markm).
This commit is contained in:
Tzu-ping Chung 2019-02-03 01:13:23 +08:00 committed by Steve Dower
parent 05e922136a
commit 2de576e16d
3 changed files with 46 additions and 12 deletions

View file

@ -555,7 +555,7 @@ summary_getproperty(msiobj* si, PyObject *args)
FILETIME fval;
char sbuf[1000];
char *sval = sbuf;
DWORD ssize = sizeof(sval);
DWORD ssize = sizeof(sbuf);
if (!PyArg_ParseTuple(args, "i:GetProperty", &field))
return NULL;
@ -563,6 +563,7 @@ summary_getproperty(msiobj* si, PyObject *args)
status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival,
&fval, sval, &ssize);
if (status == ERROR_MORE_DATA) {
ssize++;
sval = malloc(ssize);
if (sval == NULL) {
return PyErr_NoMemory();
@ -572,21 +573,29 @@ summary_getproperty(msiobj* si, PyObject *args)
}
switch(type) {
case VT_I2: case VT_I4:
return PyLong_FromLong(ival);
case VT_I2:
case VT_I4:
result = PyLong_FromLong(ival);
break;
case VT_FILETIME:
PyErr_SetString(PyExc_NotImplementedError, "FILETIME result");
return NULL;
result = NULL;
break;
case VT_LPSTR:
result = PyBytes_FromStringAndSize(sval, ssize);
if (sval != sbuf)
free(sval);
return result;
break;
case VT_EMPTY:
Py_RETURN_NONE;
Py_INCREF(Py_None);
result = Py_None;
break;
default:
PyErr_Format(PyExc_NotImplementedError, "result of type %d", type);
result = NULL;
break;
}
PyErr_Format(PyExc_NotImplementedError, "result of type %d", type);
return NULL;
if (sval != sbuf)
free(sval);
return result;
}
static PyObject*