Skip to content

Commit b253e1e

Browse files
committed
gh-144023: fd_and_follow_symlinks_invalid lets fd be 0
0 is a valid fd, so we do not want this and followsimlinks.
1 parent 59d3594 commit b253e1e

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixed validation of file descriptor 0 in posix functions when used with
2+
follow_symlinks parameter.

Modules/posixmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,7 @@ static int
16371637
fd_and_follow_symlinks_invalid(const char *function_name, int fd,
16381638
int follow_symlinks)
16391639
{
1640-
if ((fd > 0) && (!follow_symlinks)) {
1640+
if ((fd >= 0) && (!follow_symlinks)) {
16411641
PyErr_Format(PyExc_ValueError,
16421642
"%s: cannot use fd and follow_symlinks together",
16431643
function_name);

0 commit comments

Comments
 (0)