From 7d69463a689ee3f51934db4fe12de594a2d61b44 Mon Sep 17 00:00:00 2001 From: datadiode Date: Tue, 15 Oct 2024 18:16:19 +0200 Subject: [PATCH] Don't break std* file descriptors (inspired by the other is_socket() which lives in poll_win.c) --- crypto/compat/posix_win.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crypto/compat/posix_win.c b/crypto/compat/posix_win.c index 14c4430d42..e3bf13d06b 100644 --- a/crypto/compat/posix_win.c +++ b/crypto/compat/posix_win.c @@ -161,6 +161,9 @@ wsa_errno(int err) static int is_socket(int fd) { + /* Border case: Don't break std* file descriptors */ + if (fd < 3) + return 0; return (fd & 1) == 0; /* daringly assumes that any valid socket is even */ }