[haiku-commits] haiku: hrev54132 - src/add-ons/kernel/network/stack

  • From: Jérôme Duval <jerome.duval@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 4 May 2020 03:33:48 -0400 (EDT)

hrev54132 adds 1 changeset to branch 'master'
old head: 27ecd4761ca65b229d0558995fdde2fbfb415045
new head: 5c63c64bfd2cebc9010219266f2cab3d510623b3
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=5c63c64bfd2c+%5E27ecd4761ca6

----------------------------------------------------------------------------

5c63c64bfd2c: net_socket: getpeername now only works on connected socket
  
  Per POSIX.1-2008, getpeername() shall fails if the socket is not
  connected.
  
  Fixes #15081
  
  Change-Id: Iafaed09df26f47b10efc2ceed6dfa2852857d39a
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/2549
  Reviewed-by: Jérôme Duval <jerome.duval@xxxxxxxxx>
  Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

                                       [ Leorize <leorize+oss@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev54132
Commit:      5c63c64bfd2cebc9010219266f2cab3d510623b3
URL:         https://git.haiku-os.org/haiku/commit/?id=5c63c64bfd2c
Author:      Leorize <leorize+oss@xxxxxxxxxxx>
Date:        Wed Mar 25 19:15:25 2020 UTC
Committer:   Jérôme Duval <jerome.duval@xxxxxxxxx>
Commit-Date: Mon May  4 07:33:42 2020 UTC

Ticket:      https://dev.haiku-os.org/ticket/15081

----------------------------------------------------------------------------

1 file changed, 3 insertions(+), 2 deletions(-)
src/add-ons/kernel/network/stack/net_socket.cpp | 5 +++--

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/network/stack/net_socket.cpp 
b/src/add-ons/kernel/network/stack/net_socket.cpp
index 4ca9ebbf20..03297b92d3 100644
--- a/src/add-ons/kernel/network/stack/net_socket.cpp
+++ b/src/add-ons/kernel/network/stack/net_socket.cpp
@@ -1059,10 +1059,11 @@ socket_connect(net_socket* socket, const struct 
sockaddr* address,
 
 
 int
-socket_getpeername(net_socket* socket, struct sockaddr* address,
+socket_getpeername(net_socket* _socket, struct sockaddr* address,
        socklen_t* _addressLength)
 {
-       if (socket->peer.ss_len == 0)
+       net_socket_private* socket = (net_socket_private*)_socket;
+       if (!socket->is_connected || socket->peer.ss_len == 0)
                return ENOTCONN;
 
        memcpy(address, &socket->peer, min_c(*_addressLength, 
socket->peer.ss_len));


Other related posts:

  • » [haiku-commits] haiku: hrev54132 - src/add-ons/kernel/network/stack - Jérôme Duval