Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/pc/protocols/tcpip_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1095,11 +1095,15 @@ int tcpipPlatformConnect(const char *devPathRead, const char *devPathWrite, void

const size_t maxlen = 255;
size_t len = strnlen(devPathWrite, maxlen + 1);
if (len == 0 || len >= maxlen + 1)
if (len == 0 || len >= maxlen + 1) {
tcpip_close_socket(sock);
return X_LINK_PLATFORM_INVALID_PARAMETERS;
}
char *const serv_ip = (char *)malloc(len + 1);
if (!serv_ip)
if (!serv_ip) {
tcpip_close_socket(sock);
return X_LINK_PLATFORM_ERROR;
}
serv_ip[0] = 0;
// Parse port if specified, or use default
int port = TCPIP_LINK_SOCKET_PORT;
Expand Down Expand Up @@ -1188,13 +1192,17 @@ int tcpipPlatformClose(void *fdKey)
TCPIP_SOCKET sock = (TCPIP_SOCKET) (uintptr_t) tmpsockfd;

#ifdef _WIN32
status = shutdown(sock, SD_BOTH);
if (status == 0) { status = closesocket(sock); }
if(shutdown(sock, SD_BOTH)) {
mvLog(MVLOG_DEBUG, "Error shutting down socket: %d", tcpip_errno);
}
status = closesocket(sock);
#else
if(sock != -1)
{
status = shutdown(sock, SHUT_RDWR);
if (status == 0) { status = close(sock); }
if(shutdown(sock, SHUT_RDWR)) {
mvLog(MVLOG_DEBUG, "Error shutting down socket: %d", tcpip_errno);
}
status = close(sock);
}
#endif

Expand Down
Loading