Opened 16 years ago
Closed 3 years ago
#2967 closed bug (fixed)
getpeername() succeeds on unconnected sockets
Reported by: | bonefish | Owned by: | phoudoin |
---|---|---|---|
Priority: | normal | Milestone: | R1/beta2 |
Component: | Network & Internet/TCP | Version: | R1/pre-alpha1 |
Keywords: | Cc: | ||
Blocked By: | #15081 | Blocking: | |
Platform: | All |
Description
A getpeername() after a connect() on a TCP socket succeeds even if
- the socket is non-blocking and the connection has not been established, or
- the socket is blocking and connect() timed out.
In either case getpeername() should fail with ENOTCONN.
The problem seems to be that getpeername() is fully implemented in the socket module and doesn't inquire the connection state. Or that the TCP module should set the peer address only when the connection is established and unset it when disconnected.
Change History (7)
comment:1 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 9 years ago
comment:3 by , 9 years ago
Stupid fix, in fact, as it will break for connectionless sockets, like UDP. It means that, indeed, TCP module should not set peer address public until connected.
comment:4 by , 5 years ago
Blocking: | 15081 added |
---|
comment:5 by , 5 years ago
Blocked By: | 15081 added |
---|---|
Blocking: | 15081 removed |
comment:6 by , 5 years ago
Is this not fixed by hrev54132? In that case, what else needs to be done?
comment:7 by , 3 years ago
Milestone: | R1 → R1/beta2 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
An easy fix is in src/add-ons/kernel/network/stack/net_socket.cpp
Not great though, in the public socket API part of this module, net_socket_private is supposed to be unknown.