bpo-12202: Properly check MsiSummaryInfoGetProperty() calls in msilib (GH-13711)
https://github.com/python/cpython/commit/549e55a3086d04c13da9b6f33214f639968... commit: 549e55a3086d04c13da9b6f33214f6399681292a branch: master author: Zackery Spytz <zspytz@gmail.com> committer: Berker Peksag <berker.peksag@gmail.com> date: 2019-06-01T03:16:20+03:00 summary: bpo-12202: Properly check MsiSummaryInfoGetProperty() calls in msilib (GH-13711) files: A Misc/NEWS.d/next/Library/2019-05-31-15-53-34.bpo-12202.nobzc9.rst M Lib/test/test_msilib.py M PC/_msi.c diff --git a/Lib/test/test_msilib.py b/Lib/test/test_msilib.py index 265eaea59b5f..fa0be581613d 100644 --- a/Lib/test/test_msilib.py +++ b/Lib/test/test_msilib.py @@ -85,6 +85,7 @@ def test_get_property_vt_empty(self): def test_directory_start_component_keyfile(self): db, db_path = init_database() + self.addCleanup(unlink, db_path) self.addCleanup(db.Close) feature = msilib.Feature(db, 0, 'Feature', 'A feature', 'Python') cab = msilib.CAB('CAB') @@ -92,6 +93,14 @@ def test_directory_start_component_keyfile(self): 'SourceDir', 0) dir.start_component(None, feature, None, 'keyfile') + def test_getproperty_uninitialized_var(self): + db, db_path = init_database() + self.addCleanup(unlink, db_path) + self.addCleanup(db.Close) + si = db.GetSummaryInformation(0) + with self.assertRaises(msilib.MSIError): + si.GetProperty(-1) + class Test_make_id(unittest.TestCase): #http://msdn.microsoft.com/en-us/library/aa369212(v=vs.85).aspx diff --git a/Misc/NEWS.d/next/Library/2019-05-31-15-53-34.bpo-12202.nobzc9.rst b/Misc/NEWS.d/next/Library/2019-05-31-15-53-34.bpo-12202.nobzc9.rst new file mode 100644 index 000000000000..1e561970445f --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-05-31-15-53-34.bpo-12202.nobzc9.rst @@ -0,0 +1,2 @@ +Fix the error handling in :meth:`msilib.SummaryInformation.GetProperty`. Patch +by Zackery Spytz. diff --git a/PC/_msi.c b/PC/_msi.c index 4c8df5b42b95..accbe7a72069 100644 --- a/PC/_msi.c +++ b/PC/_msi.c @@ -571,6 +571,9 @@ summary_getproperty(msiobj* si, PyObject *args) status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival, &fval, sval, &ssize); } + if (status != ERROR_SUCCESS) { + return msierror(status); + } switch(type) { case VT_I2:
participants (1)
-
Berker Peksag