mirror of https://github.com/wolfSSL/wolfssh.git
Release v1.4.18: Release Testing Fixes (Windows)
1. For the ASCII and Wide versions of types and functions, make sure the wolfSSHd is being consistent using them. 2. In SFTP, use WSOCKETCLOSE to close the socket. Use the correct type for the socket. 3. Add parens around part of a ternary operator check to clear up some ambiguous order of operations. 4. Add a variable initializer for a COORD structure. 5. Add parameter checks to the Base16_Decode function. 6. Fix a double-freed handle. 7. Clean up a bunch of build warnings.pull/726/head
parent
dc2065719f
commit
1a6225671b
|
@ -151,6 +151,7 @@ static void SyslogCb(enum wolfSSH_LogLevel level, const char *const msgStr)
|
|||
|
||||
#ifdef _WIN32
|
||||
static void ServiceDebugCb(enum wolfSSH_LogLevel level, const char* const msgStr)
|
||||
#ifdef UNICODE
|
||||
{
|
||||
WCHAR* wc;
|
||||
size_t szWord = WSTRLEN(msgStr) + 3; /* + 3 for null terminator and new
|
||||
|
@ -170,7 +171,13 @@ static void ServiceDebugCb(enum wolfSSH_LogLevel level, const char* const msgStr
|
|||
}
|
||||
WOLFSSH_UNUSED(level);
|
||||
}
|
||||
#else
|
||||
{
|
||||
OutputDebugString(msgStr);
|
||||
WOLFSSH_UNUSED(level);
|
||||
}
|
||||
#endif
|
||||
#endif /* _WIN32 */
|
||||
|
||||
static void ShowUsage(void)
|
||||
{
|
||||
|
@ -674,7 +681,6 @@ static int SFTP_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
|
|||
}
|
||||
|
||||
if (ret == WS_SUCCESS) {
|
||||
r[rSz] = '\0';
|
||||
wolfSSH_Log(WS_LOG_INFO,
|
||||
"[SSHD] Using directory %s for SFTP connection", r);
|
||||
if (wolfSSH_SFTP_SetDefaultPath(ssh, r) != WS_SUCCESS) {
|
||||
|
@ -832,7 +838,6 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
|
|||
|
||||
/* @TODO check for conpty support LoadLibrary()and GetProcAddress(). */
|
||||
|
||||
|
||||
if (forcedCmd != NULL && WSTRCMP(forcedCmd, "internal-sftp") == 0) {
|
||||
wolfSSH_Log(WS_LOG_ERROR,
|
||||
"[SSHD] Only SFTP connections allowed for user "
|
||||
|
@ -912,6 +917,7 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
|
|||
if (ret == WS_SUCCESS) {
|
||||
SECURITY_ATTRIBUTES saAttr;
|
||||
|
||||
ZeroMemory(&saAttr, sizeof(saAttr));
|
||||
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
saAttr.bInheritHandle = TRUE;
|
||||
saAttr.lpSecurityDescriptor = NULL;
|
||||
|
@ -926,28 +932,30 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
|
|||
}
|
||||
|
||||
if (ret == WS_SUCCESS) {
|
||||
STARTUPINFO si;
|
||||
STARTUPINFOW si;
|
||||
PCWSTR conCmd = L"wolfsshd.exe -r ";
|
||||
PWSTR conCmdPtr;
|
||||
int conCmdSz;
|
||||
size_t conCmdSz;
|
||||
|
||||
SetHandleInformation(ptyIn, HANDLE_FLAG_INHERIT, 0);
|
||||
SetHandleInformation(ptyOut, HANDLE_FLAG_INHERIT, 0);
|
||||
|
||||
wolfSSH_SetTerminalResizeCtx(ssh, (void*)&ptyIn);
|
||||
|
||||
conCmdSz = (int)(wcslen(conCmd) + cmdSz + 2); /* +1 for terminator */
|
||||
conCmdPtr = (PWSTR)WMALLOC(sizeof(wchar_t) * conCmdSz, NULL, DYNTYPE_SSHD);
|
||||
conCmdSz = wcslen(conCmd) + cmdSz + 3;
|
||||
/* +1 for terminator, +2 for quotes */
|
||||
conCmdPtr = (PWSTR)WMALLOC(sizeof(wchar_t) * conCmdSz,
|
||||
NULL, DYNTYPE_SSHD);
|
||||
if (conCmdPtr == NULL) {
|
||||
ret = WS_MEMORY_E;
|
||||
}
|
||||
else {
|
||||
memset(conCmdPtr, 0, conCmdSz * sizeof(wchar_t));
|
||||
_snwprintf(conCmdPtr, conCmdSz * sizeof(wchar_t), L"wolfsshd.exe -r \"%s\"", cmd);
|
||||
_snwprintf_s(conCmdPtr, conCmdSz, conCmdSz,
|
||||
L"wolfsshd.exe -r \"%s\"", cmd);
|
||||
}
|
||||
|
||||
ZeroMemory(&si, sizeof(STARTUPINFO));
|
||||
si.cb = sizeof(STARTUPINFO);
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cb = sizeof(si);
|
||||
|
||||
si.hStdInput = cnslIn;
|
||||
si.hStdOutput = cnslOut;
|
||||
|
@ -967,7 +975,6 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
|
|||
CloseHandle(cnslOut);
|
||||
|
||||
WFREE(conCmdPtr, NULL, DYNTYPE_SSHD);
|
||||
CloseHandle(processInfo.hThread);
|
||||
}
|
||||
|
||||
if (ret == WS_SUCCESS) {
|
||||
|
@ -2374,21 +2381,21 @@ static int StartSSHD(int argc, char** argv)
|
|||
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Issue updating service status");
|
||||
}
|
||||
}
|
||||
if (ret == WS_SUCCESS) {
|
||||
/* Create a stop event to watch on */
|
||||
serviceStop = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
if (serviceStop == NULL) {
|
||||
serviceStatus.dwControlsAccepted = 0;
|
||||
serviceStatus.dwCurrentState = SERVICE_STOPPED;
|
||||
serviceStatus.dwWin32ExitCode = GetLastError();
|
||||
serviceStatus.dwCheckPoint = 1;
|
||||
|
||||
/* Create a stop event to watch on */
|
||||
serviceStop = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
if (serviceStop == NULL) {
|
||||
serviceStatus.dwControlsAccepted = 0;
|
||||
serviceStatus.dwCurrentState = SERVICE_STOPPED;
|
||||
serviceStatus.dwWin32ExitCode = GetLastError();
|
||||
serviceStatus.dwCheckPoint = 1;
|
||||
|
||||
if (SetServiceStatus(serviceStatusHandle, &serviceStatus) == FALSE) {
|
||||
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Issue updating service status");
|
||||
if (SetServiceStatus(serviceStatusHandle, &serviceStatus) == FALSE) {
|
||||
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Issue updating service status");
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmdArgs != NULL) {
|
||||
LocalFree(cmdArgs);
|
||||
}
|
||||
|
@ -2550,8 +2557,8 @@ static int SetupConsole(char* inCmd)
|
|||
HANDLE sOut;
|
||||
HANDLE sIn;
|
||||
HPCON pCon = 0;
|
||||
COORD cord;
|
||||
STARTUPINFOEX ext;
|
||||
COORD cord = { 80,24 }; /* Default to 80x24. Updated later. */
|
||||
STARTUPINFOEXW ext;
|
||||
int ret = WS_SUCCESS;
|
||||
PWSTR cmd = NULL;
|
||||
size_t cmdSz = 0;
|
||||
|
@ -2564,10 +2571,6 @@ static int SetupConsole(char* inCmd)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* defautl 80x24 with setup, screen size will get set by VT command after started */
|
||||
cord.X = 80;
|
||||
cord.Y = 24;
|
||||
|
||||
sIn = GetStdHandle(STD_INPUT_HANDLE);
|
||||
|
||||
if (WSTRCMP(shellCmd, inCmd) != 0) {
|
||||
|
|
|
@ -4538,9 +4538,9 @@ int SFTP_GetAttributes(void* fs, const char* fileName, WS_SFTP_FILEATRB* atr,
|
|||
|
||||
atr->flags |= WOLFSSH_FILEATRB_PERM;
|
||||
atr->per = 0555 |
|
||||
(stats.dwFileAttributes | FILE_ATTRIBUTE_READONLY ? 0 : 0200);
|
||||
atr->per |= (stats.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? 0x4000:
|
||||
FILEATRB_PER_FILE;
|
||||
((stats.dwFileAttributes | FILE_ATTRIBUTE_READONLY) ? 0 : 0200);
|
||||
atr->per |= ((stats.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
? FILEATRB_PER_DIR : FILEATRB_PER_FILE);
|
||||
|
||||
#if 0
|
||||
/* @TODO handle the constellation of possible Windows FILETIMEs */
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <wolfssl/options.h>
|
||||
#endif
|
||||
#include <wolfssl/wolfcrypt/wc_port.h>
|
||||
#include <wolfssh/port.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <wolfssh/ssh.h>
|
||||
|
@ -955,7 +956,7 @@ static void test_wolfSSH_SFTP_SendReadPacket(void)
|
|||
func_args ser;
|
||||
tcp_ready ready;
|
||||
int argsCount;
|
||||
int clientFd;
|
||||
WS_SOCKET_T clientFd;
|
||||
|
||||
const char* args[10];
|
||||
WOLFSSH_CTX* ctx = NULL;
|
||||
|
@ -1066,7 +1067,7 @@ static void test_wolfSSH_SFTP_SendReadPacket(void)
|
|||
|
||||
/* close client socket down */
|
||||
clientFd = wolfSSH_get_fd(ssh);
|
||||
close(clientFd);
|
||||
WCLOSESOCKET(clientFd);
|
||||
|
||||
wolfSSH_free(ssh);
|
||||
wolfSSH_CTX_free(ctx);
|
||||
|
|
|
@ -186,7 +186,9 @@ int wolfSSH_SftpTest(int flag)
|
|||
int argsCount;
|
||||
|
||||
const char* args[10];
|
||||
#ifndef USE_WINDOWS_API
|
||||
char portNumber[8];
|
||||
#endif
|
||||
|
||||
THREAD_TYPE serThread;
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@
|
|||
|
||||
#ifdef USE_WINDOWS_API
|
||||
#define WCLOSESOCKET(s) closesocket(s)
|
||||
#define WSTARTTCP() do { WSADATA wsd; WSAStartup(0x0002, &wsd); } while(0)
|
||||
#define WSTARTTCP() do { WSADATA wsd; (void)WSAStartup(0x0002, &wsd); } while(0)
|
||||
#elif defined(MICROCHIP_TCPIP) || defined(MICROCHIP_MPLAB_HARMONY)
|
||||
#ifdef MICROCHIP_MPLAB_HARMONY
|
||||
#define WCLOSESOCKET(s) TCPIP_TCP_Close((s))
|
||||
|
@ -1136,6 +1136,9 @@ static int Base16_Decode(const byte* in, word32 inLen,
|
|||
word32 inIdx = 0;
|
||||
word32 outIdx = 0;
|
||||
|
||||
if (in == NULL || out == NULL || outLen == NULL)
|
||||
return WS_BAD_ARGUMENT;
|
||||
|
||||
if (inLen == 1 && *outLen && in) {
|
||||
byte b = in[inIdx] - 0x30; /* 0 starts at 0x30 */
|
||||
|
||||
|
|
Loading…
Reference in New Issue