]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.8] gh-96577: Fixes buffer overrun in _msi module (GH-96633) (GH-96658)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 4 Oct 2022 18:07:09 +0000 (11:07 -0700)
committerGitHub <noreply@github.com>
Tue, 4 Oct 2022 18:07:09 +0000 (11:07 -0700)
gh-96577: Fixes buffer overrun in _msi module (GH-96633)
(cherry picked from commit 4114bcc9ef7595a07196bcecf9c7d6d39f57f64d)

Co-authored-by: Steve Dower <steve.dower@python.org>
Misc/NEWS.d/next/Windows/2022-09-07-00-11-33.gh-issue-96577.kV4K_1.rst [new file with mode: 0644]
PC/_msi.c

diff --git a/Misc/NEWS.d/next/Windows/2022-09-07-00-11-33.gh-issue-96577.kV4K_1.rst b/Misc/NEWS.d/next/Windows/2022-09-07-00-11-33.gh-issue-96577.kV4K_1.rst
new file mode 100644 (file)
index 0000000..6025e5c
--- /dev/null
@@ -0,0 +1 @@
+Fixes a potential buffer overrun in :mod:`msilib`.
index 5079a524646f0e108ad2efa460028311a12b7551..0b92712233c9b56fce80e16d55e19c677b889b83 100644 (file)
--- a/PC/_msi.c
+++ b/PC/_msi.c
@@ -292,7 +292,7 @@ msierror(int status)
     int code;
     char buf[2000];
     char *res = buf;
-    DWORD size = sizeof(buf);
+    DWORD size = Py_ARRAY_LENGTH(buf);
     MSIHANDLE err = MsiGetLastErrorRecord();
 
     if (err == 0) {
@@ -386,7 +386,7 @@ record_getstring(msiobj* record, PyObject* args)
     unsigned int status;
     WCHAR buf[2000];
     WCHAR *res = buf;
-    DWORD size = sizeof(buf);
+    DWORD size = Py_ARRAY_LENGTH(buf);
     PyObject* string;
 
     if (!PyArg_ParseTuple(args, "I:GetString", &field))