Page MenuHomePhabricator

The connector does not distinguish between a file descriptor and a socket in a Windows environment. (read()/write())
Closed, ResolvedPublic


In the functions "ssh_connector_fd_in_cb", "ssh_connector_channel_data_cb" and "ssh_connector_fd_out_cb" the "read()" and "write()" method is used, even if it is a socket.

This works in a Unix environment, not in a Windows environment.

The basic problem is that in a Windows environment a socket is not a file descriptor ( like unix ) but a handle.

Instead of "read()"/"write()" the methods "recv()"/"send()" should be used (as already used in the "socket.c").

Event Timeline

davidwed created this task.Sep 21 2018, 2:03 PM
davidwed triaged this task as High priority.
davidwed updated the task description. (Show Details)

Unfortunately it is not possible to use fstat() + S_ISSOCK or similar under Windows.

I have now used getsockname() and GetNamedPipeInfo() to determine if the file descriptor is a socket or a named pipe.

Then recv()/send() is used instead of read()/write().

New version

Newer version