diff --git a/apps/wolfssh/wolfssh.c b/apps/wolfssh/wolfssh.c index f9414d795..808953cda 100644 --- a/apps/wolfssh/wolfssh.c +++ b/apps/wolfssh/wolfssh.c @@ -563,7 +563,7 @@ static THREAD_RET readPeer(void* in) buf[bufSz - 1] = '\0'; #ifdef USE_WINDOWS_API - if (WriteFile(stdoutHandle, buf, bufSz, &writtn, NULL) == FALSE) { + if (WriteFile(stdoutHandle, buf, (DWORD)ret, &writtn, NULL) == FALSE) { err_sys("Failed to write to stdout handle"); } #else diff --git a/examples/client/client.c b/examples/client/client.c index 5ab01b19a..38e446721 100644 --- a/examples/client/client.c +++ b/examples/client/client.c @@ -546,7 +546,7 @@ static THREAD_RET readPeer(void* in) buf[bufSz - 1] = '\0'; #ifdef USE_WINDOWS_API - if (WriteFile(stdoutHandle, buf, bufSz, &writtn, NULL) == FALSE) { + if (WriteFile(stdoutHandle, buf, (DWORD)ret, &writtn, NULL) == FALSE) { err_sys("Failed to write to stdout handle"); } #else diff --git a/examples/client/common.c b/examples/client/common.c index ed7e33d7d..8f3d37652 100644 --- a/examples/client/common.c +++ b/examples/client/common.c @@ -519,6 +519,8 @@ int ClientUserAuth(byte authType, else if (authType == WOLFSSH_USERAUTH_PASSWORD) { if (defaultPassword != NULL) { passwordSz = (word32)strlen(defaultPassword); + if (passwordSz > (word32)sizeof(userPassword)) + passwordSz = (word32)sizeof(userPassword); memcpy(userPassword, defaultPassword, passwordSz); } #ifdef WOLFSSH_TERM diff --git a/examples/portfwd/portfwd.c b/examples/portfwd/portfwd.c index 355e5adb4..86521e94e 100644 --- a/examples/portfwd/portfwd.c +++ b/examples/portfwd/portfwd.c @@ -172,6 +172,8 @@ static int wsUserAuth(byte authType, (void)authType; if (defaultPassword != NULL) { passwordSz = (word32)strlen(defaultPassword); + if (passwordSz > (word32)sizeof(userPassword)) + passwordSz = (word32)sizeof(userPassword); memcpy(userPassword, defaultPassword, passwordSz); } else { diff --git a/src/wolfterm.c b/src/wolfterm.c index 7ddd5d117..8dee491f5 100644 --- a/src/wolfterm.c +++ b/src/wolfterm.c @@ -737,7 +737,7 @@ int wolfSSH_ConvertConsole(WOLFSSH* ssh, WOLFSSH_HANDLE handle, byte* buf, case 'D': /* linefeed */ - if (WS_WRITECONSOLE(handle, "\n", sizeof("\n"), &wrt, NULL) + if (WS_WRITECONSOLE(handle, "\n", sizeof("\n") - 1, &wrt, NULL) == 0) { WLOG(WS_LOG_DEBUG, "Error writing newline to handle"); return WS_FATAL_ERROR; @@ -745,7 +745,7 @@ int wolfSSH_ConvertConsole(WOLFSSH* ssh, WOLFSSH_HANDLE handle, byte* buf, break; case 'E': /* newline */ - if (WS_WRITECONSOLE(handle, "\n", sizeof("\n"), &wrt, NULL) + if (WS_WRITECONSOLE(handle, "\n", sizeof("\n") - 1, &wrt, NULL) == 0) { WLOG(WS_LOG_DEBUG, "Error writing newline to handle"); return WS_FATAL_ERROR;