-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-145335: Fix crash when passing -1 as fd in os.pathconf #145390
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Fix a crash in :func:`os.pathconf` when called with ``-1`` as the path | ||
| argument. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1609,6 +1609,12 @@ follow_symlinks_specified(const char *function_name, int follow_symlinks) | |
| return 1; | ||
| } | ||
|
|
||
| static bool | ||
| path_is_fd(const path_t *path) | ||
| { | ||
| return path->allow_fd && path->object != NULL && PyIndex_Check(path->object); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the problem really with the check or with is it with the converter?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. edit: nvm
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of checking
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||
| } | ||
|
|
||
| static int | ||
| path_and_dir_fd_invalid(const char *function_name, path_t *path, int dir_fd) | ||
| { | ||
|
|
@@ -14328,8 +14334,9 @@ os_pathconf_impl(PyObject *module, path_t *path, int name) | |
|
|
||
| errno = 0; | ||
| #ifdef HAVE_FPATHCONF | ||
| if (path->fd != -1) | ||
| if (path_is_fd(path)) { | ||
| limit = fpathconf(path->fd, name); | ||
| } | ||
| else | ||
| #endif | ||
| limit = pathconf(path->narrow, name); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.