GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-42036:Fixed unchecked return in Modules/posixmodule.c by monocle-ai · Pull Request #22696 · python/cpython

Conversation

@monocle-ai

@monocle-ai monocle-ai commented Oct 14, 2020 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Instance 1
File : Modules/posixmodule.c
Enclosing Function : os_times_impl
Function : GetProcessTimes@20
https://github.com/siva-msft/cpython/blob/582aaf19e8b94a70c1f96792197770d604ba0fdf/Modules/posixmodule.c#L8505
Issue in: user, kernel

Code extract:

    FILETIME create, exit, kernel, user;
    HANDLE hProc;
    hProc = GetCurrentProcess();
    GetProcessTimes(hProc, &create, &exit, &kernel, &user); <------ HERE
    /* The fields of a FILETIME structure are the hi and lo part
       of a 64-bit value expressed in 100 nanosecond units.

How can I fix it?
Correct reference usage found in Modules/timemodule.c at line 1133.
https://github.com/siva-msft/cpython/blob/582aaf19e8b94a70c1f96792197770d604ba0fdf/Modules/timemodule.c#L1133
Code extract:

    BOOL ok;

    process = GetCurrentProcess();
    ok = GetProcessTimes(process, &creation_time, &exit_time, <------ HERE
                         &kernel_time, &user_time);
    if (!ok) {

Instance 2
File : Modules/posixmodule.c
Enclosing Function : posixmodule_exec
Function : dir_fd_converter
https://github.com/siva-msft/cpython/blob/582aaf19e8b94a70c1f96792197770d604ba0fdf/Modules/posixmodule.c#L15060
Issue in: ignored

Code extract:

    fd_specified("", -1);
    follow_symlinks_specified("", 1);
    dir_fd_and_follow_symlinks_invalid("chmod", DEFAULT_DIR_FD, 1);
    dir_fd_converter(Py_None, &ignored); <------ HERE
    dir_fd_unavailable(Py_None, &ignored);
    }

How can I fix it?
Correct reference usage found in Modules/posixmodule.c at line 1258.
https://github.com/siva-msft/cpython/blob/582aaf19e8b94a70c1f96792197770d604ba0fdf/Modules/posixmodule.c#L1258
Code extract:

dir_fd_unavailable(PyObject *o, void *p)
{
    int dir_fd;
    if (!dir_fd_converter(o, &dir_fd)) <------ HERE
        return 0;
    if (dir_fd != DEFAULT_DIR_FD) {

https://bugs.python.org/issue42036

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
monocle-ai added 2 commits October 14, 2020 08:34
@monocle-ai
bpo-42036:Fixed unchecked return in Modules/posixmodule.c
3b6f258
**Instance 1**
File : `Modules/posixmodule.c` 
Enclosing Function : `os_times_impl`
Function : `GetProcessTimes@20` 
https://github.com/siva-msft/cpython/blob/582aaf19e8b94a70c1f96792197770d604ba0fdf/Modules/posixmodule.c#L8505
**Issue in**: _user, kernel_

**Code extract**:

```cpp
    FILETIME create, exit, kernel, user;
    HANDLE hProc;
    hProc = GetCurrentProcess();
    GetProcessTimes(hProc, &create, &exit, &kernel, &user); <------ HERE
    /* The fields of a FILETIME structure are the hi and lo part
       of a 64-bit value expressed in 100 nanosecond units.
```

**How can I fix it?** 
Correct reference usage found in `Modules/timemodule.c` at line `1133`.
https://github.com/siva-msft/cpython/blob/582aaf19e8b94a70c1f96792197770d604ba0fdf/Modules/timemodule.c#L1133
**Code extract**:

```cpp
    BOOL ok;

    process = GetCurrentProcess();
    ok = GetProcessTimes(process, &creation_time, &exit_time, <------ HERE
                         &kernel_time, &user_time);
    if (!ok) {
```


---
**Instance 2**
File : `Modules/posixmodule.c` 
Enclosing Function : `posixmodule_exec`
Function : `dir_fd_converter` 
https://github.com/siva-msft/cpython/blob/582aaf19e8b94a70c1f96792197770d604ba0fdf/Modules/posixmodule.c#L15060
**Issue in**: _ignored_

**Code extract**:

```cpp
    fd_specified("", -1);
    follow_symlinks_specified("", 1);
    dir_fd_and_follow_symlinks_invalid("chmod", DEFAULT_DIR_FD, 1);
    dir_fd_converter(Py_None, &ignored); <------ HERE
    dir_fd_unavailable(Py_None, &ignored);
    }
```

**How can I fix it?** 
Correct reference usage found in `Modules/posixmodule.c` at line `1258`.
https://github.com/siva-msft/cpython/blob/582aaf19e8b94a70c1f96792197770d604ba0fdf/Modules/posixmodule.c#L1258
**Code extract**:

```cpp
dir_fd_unavailable(PyObject *o, void *p)
{
    int dir_fd;
    if (!dir_fd_converter(o, &dir_fd)) <------ HERE
        return 0;
    if (dir_fd != DEFAULT_DIR_FD) {
```
@monocle-ai
Update posixmodule.c
184714c
@the-knights-who-say-ni the-knights-who-say-ni added the CLA not signed label Oct 14, 2020
@the-knights-who-say-ni

the-knights-who-say-ni commented Oct 14, 2020

Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

Recognized GitHub username

We couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames:

@monocle-ai

This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added the awaiting review label Oct 14, 2020
@monocle-ai
Created 2020-10-15-07-33-50.bpo-42036.MonocleAI.rst
6045037
sweeneyde
sweeneyde reviewed Oct 29, 2020
View reviewed changes
Comment thread Modules/posixmodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@monocle-ai
Complying to PEP 7
1f5be74
@github-actions

github-actions Bot commented Dec 17, 2020

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Dec 17, 2020
serhiy-storchaka
serhiy-storchaka requested changes Oct 9, 2021
View reviewed changes
Comment thread Modules/posixmodule.c
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))

@serhiy-storchaka serhiy-storchaka Oct 9, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It never fails.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Modules/posixmodule.c
ok = GetProcessTimes(hProc, &create, &exit, &kernel, &user);
if (!ok) {
PyErr_SetFromWindowsErr(0);
return -1;

@serhiy-storchaka serhiy-storchaka Oct 9, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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;

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting changes and removed awaiting review labels Oct 9, 2021
@bedevere-bot

bedevere-bot commented Oct 9, 2021

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka serhiy-storchaka removed the CLA not signed label Oct 9, 2021
@the-knights-who-say-ni the-knights-who-say-ni added the CLA not signed label Oct 9, 2021
@hugovk hugovk mentioned this pull request Feb 17, 2022
Cron job to close stale PRs python/core-workflow#93
Closed
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Feb 19, 2022
@github-actions

github-actions Bot commented Mar 21, 2022

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity. If the CLA is not signed within 14 days, it will be closed. See also https://devguide.python.org/pullrequest/#licensing

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Mar 21, 2022
@github-actions

github-actions Bot commented Apr 4, 2022

Copy link
Copy Markdown

Closing this stale PR because the CLA is still not signed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot closed this Apr 4, 2022
@monocle-ai monocle-ai mannequin mentioned this pull request Jul 3, 2026
Unchecked return in Modules/posixmodule.c from multiple function calls #86202
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sweeneyde sweeneyde sweeneyde left review comments
@serhiy-storchaka serhiy-storchaka serhiy-storchaka requested changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting changes stale Stale PR or inactive for long period of time.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@monocle-ai @the-knights-who-say-ni @bedevere-bot @serhiy-storchaka @sweeneyde
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.