]> granicus.if.org Git - python/commitdiff
bpo-12202: Properly check MsiSummaryInfoGetProperty() calls in msilib (GH-13711)
authorZackery Spytz <zspytz@gmail.com>
Sat, 1 Jun 2019 00:16:20 +0000 (18:16 -0600)
committerBerker Peksag <berker.peksag@gmail.com>
Sat, 1 Jun 2019 00:16:20 +0000 (03:16 +0300)
Lib/test/test_msilib.py
Misc/NEWS.d/next/Library/2019-05-31-15-53-34.bpo-12202.nobzc9.rst [new file with mode: 0644]
PC/_msi.c

index 265eaea59b5f4bb4837426572ea0d08b7192b78f..fa0be581613de35424f0c6536a36ce3f5ca50514 100644 (file)
@@ -85,6 +85,7 @@ class MsiDatabaseTestCase(unittest.TestCase):
 
     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 @@ class MsiDatabaseTestCase(unittest.TestCase):
                                '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 (file)
index 0000000..1e56197
--- /dev/null
@@ -0,0 +1,2 @@
+Fix the error handling in :meth:`msilib.SummaryInformation.GetProperty`. Patch
+by Zackery Spytz.
index 4c8df5b42b95c627eb04cae8d555cf3c71a58710..accbe7a7206944796bddbc7353b59772065e5e90 100644 (file)
--- 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: