* fhandler_socket.cc (fhandler_socket::af_local_connect): Drop
setting connect_state to connect_credxchg. (fhandler_socket::af_local_accept): Ditto. (fhandler_socket::recv_internal): Drop ill-advised connect_state check. Add comment so as not to repeat the exercise. * fhandler.h (enum conn_state): Drop now unneeded connect_credxchg state.
This commit is contained in:
parent
1fc5d69923
commit
b701da7f14
@ -1,3 +1,13 @@
|
||||
2014-10-26 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* fhandler_socket.cc (fhandler_socket::af_local_connect): Drop
|
||||
setting connect_state to connect_credxchg.
|
||||
(fhandler_socket::af_local_accept): Ditto.
|
||||
(fhandler_socket::recv_internal): Drop ill-advised connect_state check.
|
||||
Add comment so as not to repeat the exercise.
|
||||
* fhandler.h (enum conn_state): Drop now unneeded connect_credxchg
|
||||
state.
|
||||
|
||||
2014-10-24 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* fhandler_proc.cc (format_proc_cygdrive): Fix symlink path if cygdrive
|
||||
|
@ -75,11 +75,10 @@ enum dirent_states
|
||||
enum conn_state
|
||||
{
|
||||
unconnected = 0,
|
||||
connect_credxchg = 1,
|
||||
connect_pending = 2,
|
||||
connected = 3,
|
||||
listener = 4,
|
||||
connect_failed = 5
|
||||
connect_pending = 1,
|
||||
connected = 2,
|
||||
listener = 3,
|
||||
connect_failed = 4
|
||||
};
|
||||
|
||||
enum line_edit_status
|
||||
|
@ -405,7 +405,6 @@ fhandler_socket::af_local_connect ()
|
||||
if (no_getpeereid ())
|
||||
return 0;
|
||||
|
||||
connect_state (connect_credxchg);
|
||||
af_local_setblocking (orig_async_io, orig_is_nonblocking);
|
||||
if (!af_local_send_secret () || !af_local_recv_secret ()
|
||||
|| !af_local_send_cred () || !af_local_recv_cred ())
|
||||
@ -428,7 +427,6 @@ fhandler_socket::af_local_accept ()
|
||||
if (no_getpeereid ())
|
||||
return 0;
|
||||
|
||||
connect_state (connect_credxchg);
|
||||
af_local_setblocking (orig_async_io, orig_is_nonblocking);
|
||||
if (!af_local_recv_secret () || !af_local_send_secret ()
|
||||
|| !af_local_recv_cred () || !af_local_send_cred ())
|
||||
@ -1465,20 +1463,12 @@ fhandler_socket::recv_internal (LPWSAMSG wsamsg, bool use_recvmsg)
|
||||
static NO_COPY LPFN_WSARECVMSG WSARecvMsg;
|
||||
int orig_namelen = wsamsg->namelen;
|
||||
|
||||
/* Windows event handling does not check for the validity of the desired
|
||||
flags so we have to do it here.
|
||||
The check goes like this:
|
||||
STREAM sockets must be either connected, or they are AF_LOCAL
|
||||
sockets in the pre-connected credential exchange phase.
|
||||
All other states are disallowed. */
|
||||
if (get_socket_type () == SOCK_STREAM && connect_state () != connected
|
||||
&& (get_addr_family () != AF_LOCAL
|
||||
|| connect_state () != connect_credxchg))
|
||||
{
|
||||
WSASetLastError (WSAENOTCONN);
|
||||
set_winsock_errno ();
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
/* CV 2014-10-26: Do not check for the connect_state at this point. In
|
||||
certain scenarios there's no way to check the connect state reliably.
|
||||
Example (hexchat): Parent process creates socket, forks, child process
|
||||
calls connect, parent process calls read. Even if the event handling
|
||||
allows to check for FD_CONNECT in the parent, there is always yet another
|
||||
scenario we can easily break. */
|
||||
|
||||
DWORD wait_flags = wsamsg->dwFlags;
|
||||
bool waitall = !!(wait_flags & MSG_WAITALL);
|
||||
|
@ -68,8 +68,7 @@ Bug Fixes
|
||||
Addresses: https://cygwin.com/ml/cygwin-developers/2014-10/msg00010.html
|
||||
|
||||
- Don't hang in accept calls if socket is no listener. Set errno to EINVAL
|
||||
instead. Don't hang in read/recv/recvfrom/recvmsg calls if socket is
|
||||
connection oriented and not connected. Set errno to ENOTCONN instead.
|
||||
instead.
|
||||
|
||||
- Don't allow seeking on serial lines and sockets. Set errno to ESPIPE
|
||||
instead.
|
||||
|
Loading…
x
Reference in New Issue
Block a user