Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-144023: prevent follow_symlinks from being allowed with an fd of 0#144022

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
serhiy-storchaka merged 1 commit intopython:mainfromSiliconA-Z:careful
Jan 20, 2026

Conversation

@SiliconA-Z
Copy link
Contributor

@SiliconA-ZSiliconA-Z commentedJan 19, 2026
edited
Loading

fd_and_follow_symlinks_invalid lets you use fd and follow_symlinks together if fd is 0.

This is incorrect, as 0 is a valid fd.

@SiliconA-ZSiliconA-Z changed the titleposixmodule: fd_and_follow_symlinks_invalid lets fd be 0gh-144023: fd_and_follow_symlinks_invalid lets fd be 0Jan 19, 2026
@SiliconA-ZSiliconA-Zforce-pushed thecareful branch 2 times, most recently from5e70bef tob253e1eCompareJanuary 19, 2026 05:58
@SiliconA-ZSiliconA-Z changed the titlegh-144023: fd_and_follow_symlinks_invalid lets fd be 0gh-144023: prevent follow_symlinks from being allowed with an fd of 0Jan 19, 2026
Copy link
Member

@sobolevnsobolevn left a comment

Choose a reason for hiding this comment

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

Is there any way to test this?

@vstinner
Copy link
Member

Is there any way to test this?

stat(0) can be be used for example.

Current behavior:

>>> os.stat(1, follow_symlinks=False)Traceback (most recent call last):  File "<python-input-2>", line 1, in <module>    os.stat(1, follow_symlinks=False)    ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^ValueError: stat: cannot use fd and follow_symlinks together>>> os.stat(0, follow_symlinks=False)os.stat_result(st_mode=8576, st_ino=4, st_dev=27, st_nlink=1, st_uid=1000, st_gid=5, st_size=0, st_atime=1768842168, st_mtime=1768842168, st_ctime=1768841838)

…d of 0fd_and_follow_symlinks_invalid lets you use fd and follow_symlinks together if fd is 0.This is incorrect, as 0 is a valid fd.
@SiliconA-Z
Copy link
ContributorAuthor

Is there any way to test this?

stat(0) can be be used for example.

Current behavior:

>>> os.stat(1, follow_symlinks=False)Traceback (most recent call last):  File "<python-input-2>", line 1, in <module>    os.stat(1, follow_symlinks=False)    ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^ValueError: stat: cannot use fd and follow_symlinks together>>> os.stat(0, follow_symlinks=False)os.stat_result(st_mode=8576, st_ino=4, st_dev=27, st_nlink=1, st_uid=1000, st_gid=5, st_size=0, st_atime=1768842168, st_mtime=1768842168, st_ctime=1768841838)

Thank you!

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

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

Good catch. LGTM. 👍

Copy link
Member

@sobolevnsobolevn left a comment

Choose a reason for hiding this comment

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

Thank you!

@sobolevnsobolevn added needs backport to 3.13bugs and security fixes needs backport to 3.14bugs and security fixes labelsJan 20, 2026
@serhiy-storchakaserhiy-storchaka merged commitfa44efa intopython:mainJan 20, 2026
55 checks passed
@miss-islington-app
Copy link

Thanks @AZero13 for the PR, and@serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington-app
Copy link

Sorry, @AZero13 and@serhiy-storchaka, I could not cleanly backport this to3.14 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker fa44efa0ef1972ac1e2f66996303154be11f605e 3.14

@miss-islington-app
Copy link

Sorry,@AZero13 and@serhiy-storchaka, I could not cleanly backport this to3.13 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker fa44efa0ef1972ac1e2f66996303154be11f605e 3.13

@SiliconA-ZSiliconA-Z deleted the careful branchJanuary 20, 2026 15:29
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull requestJan 22, 2026
…th an fd of 0 (pythonGH-144022)The check was (fd > 0), should be (fd >= 0).(cherry picked from commitfa44efa)Co-authored-by: AZero13 <gfunni234@gmail.com>
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull requestJan 22, 2026
…th an fd of 0 (pythonGH-144022)The check was (fd > 0), should be (fd >= 0).(cherry picked from commitfa44efa)Co-authored-by: AZero13 <gfunni234@gmail.com>
@bedevere-app
Copy link

GH-144151 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelJan 22, 2026
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull requestJan 22, 2026
…th an fd of 0 (pythonGH-144022)The check was (fd > 0), should be (fd >= 0).(cherry picked from commitfa44efa)Co-authored-by: AZero13 <gfunni234@gmail.com>
@bedevere-app
Copy link

GH-144152 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelJan 22, 2026
vstinner pushed a commit that referenced this pull requestJan 22, 2026
…n fd of 0 (GH-144022) (#144152)[3.13]gh-144023: Prevent follow_symlinks from being allowed with an fd of 0 (GH-144022)The check was (fd > 0), should be (fd >= 0).(cherry picked from commitfa44efa)Co-authored-by: AZero13 <gfunni234@gmail.com>
vstinner pushed a commit that referenced this pull requestJan 22, 2026
…n fd of 0 (GH-144022) (#144151)[3.14]gh-144023: Prevent follow_symlinks from being allowed with an fd of 0 (GH-144022)The check was (fd > 0), should be (fd >= 0).(cherry picked from commitfa44efa)Co-authored-by: AZero13 <gfunni234@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@serhiy-storchakaserhiy-storchakaserhiy-storchaka approved these changes

@sobolevnsobolevnsobolevn approved these changes

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@SiliconA-Z@vstinner@serhiy-storchaka@sobolevn

[8]ページ先頭

©2009-2026 Movatter.jp