Skip to content

bpo-42036:Fixed unchecked return in Modules/posixmodule.c #22696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix unchecked return in Modules/posixmodule.c. The return value of a function that is potentially used to initialize a local variable is not checked. Therefore, reading the local variable may result in an undefined behavior.
12 changes: 10 additions & 2 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -8490,7 +8490,12 @@ os_times_impl(PyObject *module)
FILETIME create, exit, kernel, user;
HANDLE hProc;
hProc = GetCurrentProcess();
GetProcessTimes(hProc, &create, &exit, &kernel, &user);
BOOL ok;
ok = GetProcessTimes(hProc, &create, &exit, &kernel, &user);
if (!ok) {
PyErr_SetFromWindowsErr(0);
return -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not even compiled.

Suggested change
return -1;
return NULL;

}
/* The fields of a FILETIME structure are the hi and lo part
of a 64-bit value expressed in 100 nanosecond units.
1e7 is one second in such units; 1e-7 the inverse.
Expand Down Expand Up @@ -15022,7 +15027,10 @@ posixmodule_exec(PyObject *m)
fd_specified("", -1);
follow_symlinks_specified("", 1);
dir_fd_and_follow_symlinks_invalid("chmod", DEFAULT_DIR_FD, 1);
dir_fd_converter(Py_None, &ignored);
if(!dir_fd_converter(Py_None, &ignored))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It never fails.

{
return 0;
}
dir_fd_unavailable(Py_None, &ignored);
}

Expand Down