[Python-checkins] bpo-35890: Use RegQueryInfoKeyW and CryptAcquireContextW explicitly (GH-19974)

Miss Islington (bot) webhook-mailer at python.org
Mon May 18 13:10:03 EDT 2020


https://github.com/python/cpython/commit/460eac20a625d5dcef409dadc120a26d272a8013
commit: 460eac20a625d5dcef409dadc120a26d272a8013
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-05-18T10:09:59-07:00
summary:

bpo-35890: Use RegQueryInfoKeyW and CryptAcquireContextW explicitly (GH-19974)

(cherry picked from commit 98e42d1f882b9b59f587d538c562dbc7d11c64c3)

Co-authored-by: Minmin Gong <gongminmin at msn.com>

files:
M PC/getpathp.c
M PC/winreg.c
M Python/bootstrap_hash.c

diff --git a/PC/getpathp.c b/PC/getpathp.c
index 3747ffb2d89f0..53653c81fb45f 100644
--- a/PC/getpathp.c
+++ b/PC/getpathp.c
@@ -405,7 +405,7 @@ getpythonregpath(HKEY keyBase, int skipcore)
         goto done;
     }
     /* Find out how big our core buffer is, and how many subkeys we have */
-    rc = RegQueryInfoKey(newKey, NULL, NULL, NULL, &numKeys, NULL, NULL,
+    rc = RegQueryInfoKeyW(newKey, NULL, NULL, NULL, &numKeys, NULL, NULL,
                     NULL, NULL, &dataSize, NULL, NULL);
     if (rc!=ERROR_SUCCESS) {
         goto done;
diff --git a/PC/winreg.c b/PC/winreg.c
index 5dff7deadf767..caad18e045bcb 100644
--- a/PC/winreg.c
+++ b/PC/winreg.c
@@ -1451,9 +1451,9 @@ winreg_QueryInfoKey_impl(PyObject *module, HKEY key)
     if (PySys_Audit("winreg.QueryInfoKey", "n", (Py_ssize_t)key) < 0) {
         return NULL;
     }
-    if ((rc = RegQueryInfoKey(key, NULL, NULL, 0, &nSubKeys, NULL, NULL,
-                              &nValues,  NULL,  NULL, NULL, &ft))
-                              != ERROR_SUCCESS) {
+    if ((rc = RegQueryInfoKeyW(key, NULL, NULL, 0, &nSubKeys, NULL, NULL,
+                               &nValues,  NULL,  NULL, NULL, &ft))
+                               != ERROR_SUCCESS) {
         return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryInfoKey");
     }
     li.LowPart = ft.dwLowDateTime;
diff --git a/Python/bootstrap_hash.c b/Python/bootstrap_hash.c
index 43f5264d86250..eb2b6d08d8e14 100644
--- a/Python/bootstrap_hash.c
+++ b/Python/bootstrap_hash.c
@@ -38,8 +38,8 @@ static int
 win32_urandom_init(int raise)
 {
     /* Acquire context */
-    if (!CryptAcquireContext(&hCryptProv, NULL, NULL,
-                             PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
+    if (!CryptAcquireContextW(&hCryptProv, NULL, NULL,
+                              PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
         goto error;
 
     return 0;



More information about the Python-checkins mailing list