Skip to content

Commit 46b6fd0

Browse files
committed
gh-144023: prevent follow_symlinks from being allowed with an fd of 0
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.
1 parent 59d3594 commit 46b6fd0

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
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)