mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-35161: Fix stack-use-after-scope in grp.getgr{nam,gid} and pwd.getpw{nam,uid}. (GH-10319)
Reported by ASAN.
This commit is contained in:
parent
52465e1b8b
commit
e359bc24b1
2 changed files with 8 additions and 4 deletions
|
@ -124,11 +124,12 @@ grp_getgrgid_impl(PyObject *module, PyObject *id)
|
|||
Py_DECREF(py_int_id);
|
||||
}
|
||||
#ifdef HAVE_GETGRGID_R
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
int status;
|
||||
Py_ssize_t bufsize;
|
||||
/* Note: 'grp' will be used via pointer 'p' on getgrgid_r success. */
|
||||
struct group grp;
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
bufsize = sysconf(_SC_GETGR_R_SIZE_MAX);
|
||||
if (bufsize == -1) {
|
||||
bufsize = DEFAULT_BUFFER_SIZE;
|
||||
|
@ -204,11 +205,12 @@ grp_getgrnam_impl(PyObject *module, PyObject *name)
|
|||
if (PyBytes_AsStringAndSize(bytes, &name_chars, NULL) == -1)
|
||||
goto out;
|
||||
#ifdef HAVE_GETGRNAM_R
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
int status;
|
||||
Py_ssize_t bufsize;
|
||||
/* Note: 'grp' will be used via pointer 'p' on getgrnam_r success. */
|
||||
struct group grp;
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
bufsize = sysconf(_SC_GETGR_R_SIZE_MAX);
|
||||
if (bufsize == -1) {
|
||||
bufsize = DEFAULT_BUFFER_SIZE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue