Title: gh-145335: Fix crash when passing -1 as fd in os.pathconf by aisk · Pull Request #145390 · python/cpython · GitHub
Open Graph Title: gh-145335: Fix crash when passing -1 as fd in os.pathconf by aisk · Pull Request #145390 · python/cpython
X Title: gh-145335: Fix crash when passing -1 as fd in os.pathconf by aisk · Pull Request #145390 · python/cpython
Description: We currently test whether path_t.fd is -1 to decide if the argument should be treated as an fd or as a path, and then call fpathconf() or pathconf() according to it. In the original issue, we passing -1 caused the code incorrectly treats the argument as a real path. But, path->narrow is NULL, so calling pathconf() on it will crash the interpreter. This change adds a helper that checks whether the original argument is index-like to determine if it's an fd, so we can correctly the behavior and avoid the crash. There are other os functions that accept path_t and may have the same issue. Since that is outside the scope of the original issue, I think we should fix those in a separate PR. Issue: gh-145335
Open Graph Description: We currently test whether path_t.fd is -1 to decide if the argument should be treated as an fd or as a path, and then call fpathconf() or pathconf() according to it. In the original issue, we passi...
X Description: We currently test whether path_t.fd is -1 to decide if the argument should be treated as an fd or as a path, and then call fpathconf() or pathconf() according to it. In the original issue, we passi...
Opengraph URL: https://github.com/python/cpython/pull/145390
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:fcce4ab8-b3bf-2450-c8fa-aba1e0f0a9a8 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A58C:2B6801:4AA4B7:646B71:6A5341BC |
| html-safe-nonce | 59a05f247959e71c7ae58a8fee0ea9838fc54edb6fd25bbb934d51f4913b4306 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNThDOjJCNjgwMTo0QUE0Qjc6NjQ2QjcxOjZBNTM0MUJDIiwidmlzaXRvcl9pZCI6Ijk2ODE5NzUyMjc5MDIzNjYwNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 15c31678f6c159b8f8904145ce9596d1ae04c3f5f7505077c9c92e517ceec265 |
| hovercard-subject-tag | pull_request:3340803929 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/pull/145390/files |
| twitter:image | https://avatars.githubusercontent.com/u/699636?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/699636?s=400&v=4 |
| og:image:alt | We currently test whether path_t.fd is -1 to decide if the argument should be treated as an fd or as a path, and then call fpathconf() or pathconf() according to it. In the original issue, we passi... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width