diff --git a/examples/echoserver/echoserver.c b/examples/echoserver/echoserver.c index f3125aba..0b2788ac 100644 --- a/examples/echoserver/echoserver.c +++ b/examples/echoserver/echoserver.c @@ -87,6 +87,7 @@ #define SOCKET_ECONNABORTED ECONNABORTED #define SOCKET_EWOULDBLOCK EWOULDBLOCK #else + #include #define SOCKET_ERRNO WSAGetLastError() #define SOCKET_ECONNRESET WSAECONNRESET #define SOCKET_ECONNABORTED WSAECONNABORTED @@ -375,9 +376,10 @@ static int wolfSSH_AGENT_DefaultActions(WS_AgentCbAction action, void* vCtx) #ifdef WOLFSSH_FWD -static int connect_addr(const char* name, word16 port) +static WS_SOCKET_T connect_addr(const char* name, word16 port) { - int newSocket = -1, ret; + WS_SOCKET_T newSocket = -1; + int ret; struct addrinfo hints, *hint, *hint0 = NULL; char portStr[6]; @@ -399,7 +401,8 @@ static int connect_addr(const char* name, word16 port) if (newSocket < 0) continue; - if (connect(newSocket, hint->ai_addr, hint->ai_addrlen) < 0) { + if (connect(newSocket, hint->ai_addr, + (WS_SOCKLEN_T)hint->ai_addrlen) < 0) { WCLOSESOCKET(newSocket); newSocket = -1; continue; @@ -421,7 +424,7 @@ static int wolfSSH_FwdDefaultActions(WS_FwdCbAction action, void* vCtx, int ret = 0; if (action == WOLFSSH_FWD_LOCAL_SETUP) { - ctx->hostName = strdup(name); + ctx->hostName = WSTRDUP(name, NULL, 0); ctx->hostPort = port; ctx->isDirect = 1; ctx->state = FWD_STATE_DIRECT; @@ -439,7 +442,7 @@ static int wolfSSH_FwdDefaultActions(WS_FwdCbAction action, void* vCtx, ctx->state = FWD_STATE_INIT; } else if (action == WOLFSSH_FWD_REMOTE_SETUP) { - ctx->hostName = strdup(name); + ctx->hostName = WSTRDUP(name, NULL, 0); ctx->hostPort = port; ctx->listenFd = socket(AF_INET, SOCK_STREAM, 0); @@ -1061,7 +1064,8 @@ static int ssh_worker(thread_ctx_t* threadCtx) } } if (out != NULL) { - threadCtx->fwdCbCtx.originName = strdup(addr); + threadCtx->fwdCbCtx.originName = + WSTRDUP(addr, NULL, 0); threadCtx->fwdCbCtx.originPort = ntohs(originAddr.sin6_port); } diff --git a/wolfssh/port.h b/wolfssh/port.h index fc0271b8..7e24a9a5 100644 --- a/wolfssh/port.h +++ b/wolfssh/port.h @@ -1247,8 +1247,10 @@ extern "C" { #if defined(USE_WINDOWS_API) #define WS_SOCKET_T SOCKET + #define WS_SOCKLEN_T int #else #define WS_SOCKET_T int + #define WS_SOCKLEN_T socklen_t #endif