diff --git a/src/add-ons/kernel/network/stack/net_socket.cpp b/src/add-ons/kernel/network/stack/net_socket.cpp index 786f4c534a..1ca62fa22d 100644 --- a/src/add-ons/kernel/network/stack/net_socket.cpp +++ b/src/add-ons/kernel/network/stack/net_socket.cpp @@ -560,8 +560,11 @@ socket_get_next_stat(uint32* _cookie, int family, struct net_stat* stat) SocketList::Iterator iterator = sSocketList.GetIterator(); uint32 cookie = *_cookie; uint32 count = 0; - while (iterator.HasNext()) { + + while (true) { socket = iterator.Next(); + if (socket == NULL) + return B_ENTRY_NOT_FOUND; // TODO: also traverse the pending connections if (count == cookie) @@ -571,9 +574,6 @@ socket_get_next_stat(uint32* _cookie, int family, struct net_stat* stat) count++; } - if (socket == NULL) - return B_ENTRY_NOT_FOUND; - *_cookie = count + 1; stat->family = socket->family; diff --git a/src/system/kernel/fs/socket.cpp b/src/system/kernel/fs/socket.cpp index de4d15dbaf..8d0895a04e 100644 --- a/src/system/kernel/fs/socket.cpp +++ b/src/system/kernel/fs/socket.cpp @@ -1248,7 +1248,7 @@ _user_get_next_socket_stat(int family, uint32 *_cookie, struct net_stat *_stat) uint32 cookie; if (!IS_USER_ADDRESS(_stat) || !IS_USER_ADDRESS(_cookie) - || user_memcpy(&cookie, _cookie, sizeof(cookie)) != B_OK) { + || user_memcpy(&cookie, _cookie, sizeof(cookie)) != B_OK) { return B_BAD_ADDRESS; }