diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-05-01 08:44:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-01 08:44:11 +0200 |
commit | 9834b690aea8ecd6fb079a772df5664ff1bae618 (patch) | |
tree | 4378dedf717e6f045caaa7abf748486e3af4d300 /modules/websocket/lws_peer.cpp | |
parent | 4cce6f34170d693be994d9a451b4b5f96a084cfb (diff) | |
parent | 03bf783f3ce9d2a865bc509035dd883ffe0baa0c (diff) |
Merge pull request #18334 from Faless/coverity_net
Various coverity scan fixes, WS FreeBSD fixes
Diffstat (limited to 'modules/websocket/lws_peer.cpp')
-rw-r--r-- | modules/websocket/lws_peer.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/modules/websocket/lws_peer.cpp b/modules/websocket/lws_peer.cpp index 8a064fb5a4..3855a39aef 100644 --- a/modules/websocket/lws_peer.cpp +++ b/modules/websocket/lws_peer.cpp @@ -35,6 +35,7 @@ // Needed for socket_helpers on Android at least. UNIXes has it, just include if not windows #if !defined(WINDOWS_ENABLED) #include <netinet/in.h> +#include <sys/socket.h> #endif #include "drivers/unix/socket_helpers.h" @@ -190,9 +191,11 @@ IP_Address LWSPeer::get_connected_host() const { IP_Address ip; int port = 0; - socklen_t len; + socklen_t len = 0; struct sockaddr_storage addr; + int fd = lws_get_socket_fd(wsi); + ERR_FAIL_COND_V(fd == -1, IP_Address()); int ret = getpeername(fd, (struct sockaddr *)&addr, &len); ERR_FAIL_COND_V(ret != 0, IP_Address()); @@ -209,9 +212,11 @@ uint16_t LWSPeer::get_connected_port() const { IP_Address ip; int port = 0; - socklen_t len; + socklen_t len = 0; struct sockaddr_storage addr; + int fd = lws_get_socket_fd(wsi); + ERR_FAIL_COND_V(fd == -1, 0); int ret = getpeername(fd, (struct sockaddr *)&addr, &len); ERR_FAIL_COND_V(ret != 0, 0); |