diff --git a/.gitignore b/.gitignore index 6f0f4214a..c73676e9b 100644 --- a/.gitignore +++ b/.gitignore @@ -74,6 +74,7 @@ client.plist *.sdf *.v11.suo *.vcxproj.filters +*.vcxproj.user *.opensdf *.pdb .vs diff --git a/apps/wolfsshd/auth.c b/apps/wolfsshd/auth.c index f260ff3a8..4b4040dab 100644 --- a/apps/wolfsshd/auth.c +++ b/apps/wolfsshd/auth.c @@ -24,6 +24,8 @@ #ifdef WOLFSSL_USER_SETTINGS #include +#else + #include #endif #ifdef WOLFSSH_SSHD @@ -522,8 +524,8 @@ static int SearchForPubKey(const char* path, const WS_UserAuthData_PublicKey* pu } } while (ret == WSSHD_AUTH_SUCCESS && - (current = XFGETS(lineBuf, MAX_LINE_SZ, f)) != NULL) { - currentSz = (word32)XSTRLEN(current); + (current = WFGETS(lineBuf, MAX_LINE_SZ, f)) != NULL) { + currentSz = (word32)WSTRLEN(current); /* remove leading spaces */ while (currentSz > 0 && current[0] == ' ') { @@ -551,7 +553,7 @@ static int SearchForPubKey(const char* path, const WS_UserAuthData_PublicKey* pu } } - if (f != XBADFILE) { + if (f != WBADFILE) { WFCLOSE(f); } @@ -977,7 +979,7 @@ static int CheckPublicKeyWIN(const char* usr, wolfSSH_Log(WS_LOG_INFO, "[SSHD] Windows check public key"); ret = SetupUserTokenWin(usr, pubKeyCtx,usrCaKeysFile, authCtx); - + /* after successful logon check the public key sent */ if (ret == WSSHD_AUTH_SUCCESS) { WCHAR h[MAX_PATH]; @@ -985,7 +987,7 @@ static int CheckPublicKeyWIN(const char* usr, if (_GetHomeDirectory(authCtx, usr, h, MAX_PATH) == WS_SUCCESS) { CHAR r[MAX_PATH]; size_t rSz; - + if (wcstombs_s(&rSz, r, MAX_PATH, h, MAX_PATH - 1) != 0) { ret = WSSHD_AUTH_FAILURE; } @@ -1002,8 +1004,8 @@ static int CheckPublicKeyWIN(const char* usr, } } else { - wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Windows failed to get home directory for user %s", - usr); + wolfSSH_Log(WS_LOG_ERROR, + "[SSHD] Windows failed to get home directory for user %s", usr); ret = WSSHD_AUTH_FAILURE; } } @@ -1088,7 +1090,7 @@ static int RequestAuthentication(WS_UserAuthData* authData, } else { rc = authCtx->checkPasswordCb(usr, authData->sf.password.password, - authData->sf.password.passwordSz, authCtx); + authData->sf.password.passwordSz, authCtx); if (rc == WSSHD_AUTH_SUCCESS) { wolfSSH_Log(WS_LOG_INFO, "[SSHD] Password ok."); } @@ -1195,7 +1197,8 @@ static int RequestAuthentication(WS_UserAuthData* authData, ret = WOLFSSH_USERAUTH_SUCCESS; } else { - wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Error getting users token."); + wolfSSH_Log(WS_LOG_ERROR, + "[SSHD] Error getting users token."); ret = WOLFSSH_USERAUTH_FAILURE; } #else @@ -1205,17 +1208,20 @@ static int RequestAuthentication(WS_UserAuthData* authData, else { /* if not a certificate then parse through authorized key file */ rc = authCtx->checkPublicKeyCb(usr, &authData->sf.publicKey, - wolfSSHD_ConfigGetUserCAKeysFile(authCtx->conf), authCtx); + wolfSSHD_ConfigGetUserCAKeysFile(authCtx->conf), + authCtx); if (rc == WSSHD_AUTH_SUCCESS) { wolfSSH_Log(WS_LOG_INFO, "[SSHD] Public key ok."); ret = WOLFSSH_USERAUTH_SUCCESS; } else if (rc == WSSHD_AUTH_FAILURE) { - wolfSSH_Log(WS_LOG_INFO, "[SSHD] Public key not authorized."); + wolfSSH_Log(WS_LOG_INFO, + "[SSHD] Public key not authorized."); ret = WOLFSSH_USERAUTH_INVALID_PUBLICKEY; } else { - wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Error checking public key."); + wolfSSH_Log(WS_LOG_ERROR, + "[SSHD] Error checking public key."); ret = WOLFSSH_USERAUTH_FAILURE; } } @@ -1403,7 +1409,8 @@ WOLFSSHD_AUTH* wolfSSHD_AuthCreateUser(void* heap, const WOLFSSHD_CONFIG* conf) /* set the default user checking based on build */ ret = SetDefaultUserCheck(auth); if (ret != WS_SUCCESS) { - wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Error setting default user check."); + wolfSSH_Log(WS_LOG_ERROR, + "[SSHD] Error setting default user check."); } /* set the default password checking based on build */ diff --git a/apps/wolfsshd/configuration.c b/apps/wolfsshd/configuration.c index 8f0ffd715..498e93ff8 100644 --- a/apps/wolfsshd/configuration.c +++ b/apps/wolfsshd/configuration.c @@ -24,6 +24,8 @@ #ifdef WOLFSSL_USER_SETTINGS #include +#else + #include #endif #ifdef WOLFSSH_SSHD diff --git a/apps/wolfsshd/wolfsshd.c b/apps/wolfsshd/wolfsshd.c index 824631e3f..5b0f4c314 100644 --- a/apps/wolfsshd/wolfsshd.c +++ b/apps/wolfsshd/wolfsshd.c @@ -24,6 +24,8 @@ #ifdef WOLFSSL_USER_SETTINGS #include +#else + #include #endif #ifdef WOLFSSH_SSHD @@ -152,12 +154,13 @@ static void SyslogCb(enum wolfSSH_LogLevel level, const char *const msgStr) static void ServiceDebugCb(enum wolfSSH_LogLevel level, const char* const msgStr) { WCHAR* wc; - size_t szWord = WSTRLEN(msgStr) + 3; /* + 3 for null terminator and new line */ + size_t szWord = WSTRLEN(msgStr) + 3; /* + 3 for null terminator and new + * line */ size_t sz = szWord *sizeof(wchar_t); wc = (WCHAR*)WMALLOC(sz, NULL, DYNAMIC_TYPE_LOG); if (wc) { size_t con; - + if (mbstowcs_s(&con, wc, szWord, msgStr, szWord-1) == 0) { wc[con - 1] = L'\r'; wc[con] = L'\n'; @@ -499,7 +502,8 @@ static int SCP_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh, #ifndef _WIN32 /* temporarily elevate permissions to get users information */ if (wolfSSHD_AuthRaisePermissions(conn->auth) != WS_SUCCESS) { - wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Failure to raise permissions for auth"); + wolfSSH_Log(WS_LOG_ERROR, + "[SSHD] Failure to raise permissions for auth"); return WS_FATAL_ERROR; } @@ -592,7 +596,8 @@ static int SFTP_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh, #ifndef _WIN32 /* temporarily elevate permissions to get users information */ if (wolfSSHD_AuthRaisePermissions(conn->auth) != WS_SUCCESS) { - wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Failure to raise permissions for auth"); + wolfSSH_Log(WS_LOG_ERROR, + "[SSHD] Failure to raise permissions for auth"); return WS_FATAL_ERROR; } @@ -661,7 +666,8 @@ 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); + wolfSSH_Log(WS_LOG_INFO, + "[SSHD] Using directory %s for SFTP connection", r); if (wolfSSH_SFTP_SetDefaultPath(ssh, r) != WS_SUCCESS) { wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Error setting SFTP default home path"); @@ -816,7 +822,7 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh, /* @TODO check for conpty support LoadLibrary()and GetProcAddress(). */ - if (forcedCmd != NULL && XSTRCMP(forcedCmd, "internal-sftp") == 0) { + if (forcedCmd != NULL && WSTRCMP(forcedCmd, "internal-sftp") == 0) { wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Only SFTP connections allowed for user " "%s", wolfSSH_GetUsername(ssh)); @@ -841,11 +847,12 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh, ret = WS_MEMORY_E; } else { - WCHAR* tmp = (WCHAR*)WMALLOC(sizeof(wchar_t) * cmdSz, NULL, DYNTYPE_SSHD); + WCHAR* tmp = (WCHAR*)WMALLOC(sizeof(wchar_t) * cmdSz, NULL, + DYNTYPE_SSHD); if (tmp == NULL) { ret = WS_MEMORY_E; } - + if (ret == WS_SUCCESS) { size_t wr = 0; if (mbstowcs_s(&wr, tmp, cmdSz, forcedCmd, cmdSz - 1) != 0) { @@ -931,7 +938,8 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh, if (ret == WS_SUCCESS) { /* Using HeapAlloc for better support when possibly passing memory between Windows Modules */ - ext.lpAttributeList = (PPROC_THREAD_ATTRIBUTE_LIST)HeapAlloc(GetProcessHeap(), 0, sz); + ext.lpAttributeList = + (PPROC_THREAD_ATTRIBUTE_LIST)HeapAlloc(GetProcessHeap(), 0, sz); if (ext.lpAttributeList == NULL) { wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Issue getting memory for attribute list"); @@ -940,7 +948,8 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh, } if (ret == WS_SUCCESS) { - if (InitializeProcThreadAttributeList(ext.lpAttributeList, 1, 0, &sz) != TRUE) { + if (InitializeProcThreadAttributeList(ext.lpAttributeList, 1, 0, + &sz) != TRUE) { wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Issue initializing proc thread attribute"); ret = WS_FATAL_ERROR; @@ -948,8 +957,9 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh, } if (ret == WS_SUCCESS) { - if (UpdateProcThreadAttribute(ext.lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE, - pCon, sizeof(HPCON), NULL, NULL) != TRUE) { + if (UpdateProcThreadAttribute(ext.lpAttributeList, 0, + PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE, + pCon, sizeof(HPCON), NULL, NULL) != TRUE) { wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Issue updating proc thread attribute"); ret = WS_FATAL_ERROR; @@ -969,8 +979,8 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh, } #else /* Needs enabled when running as non-service, compiled out for now to - * make sure it can not accediently be used since the permissions of the - * created process match the current process. */ + * make sure it can not accidentally be used since the permissions of + * the created process match the current process. */ if (CreateProcessW(NULL, cmd, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT, NULL, h, &ext.StartupInfo, &processInfo) != TRUE) { @@ -1003,8 +1013,8 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh, FD_ZERO(&readFds); FD_SET(sshFd, &readFds); - wolfSSH_Log(WS_LOG_INFO, - "[SSHD] Successfully created process for console, waiting for it to start"); + wolfSSH_Log(WS_LOG_INFO, "[SSHD] Successfully created process for " + "console, waiting for it to start"); WaitForInputIdle(processInfo.hProcess, 1000); @@ -1018,14 +1028,19 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh, if (readPending == 0) { /* check if process is still running before waiting to read */ - if (GetExitCodeProcess(processInfo.hProcess, &processState) == TRUE) { + if (GetExitCodeProcess(processInfo.hProcess, &processState) + == TRUE) { if (processState != STILL_ACTIVE) { wolfSSH_Log(WS_LOG_INFO, - "[SSHD] Process has exited, exit state = %d, close down SSH connection", processState); - Sleep(100); /* give the stdout/stderr of process a little time to write to pipe */ - if (PeekNamedPipe(ptyOut, NULL, 0, NULL, &ava, NULL) == TRUE) { + "[SSHD] Process has exited, exit state = %d, " + "close down SSH connection", processState); + Sleep(100); /* give the stdout/stderr of process a + * little time to write to pipe */ + if (PeekNamedPipe(ptyOut, NULL, 0, NULL, &ava, NULL) + == TRUE) { if (ava > 0) { - /* if data still pending then continue sneding it over SSH */ + /* if data still pending then continue + * sending it over SSH */ readPending = 1; continue; } @@ -1041,7 +1056,8 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh, break; } /* when select times out and no socket is set as ready - Windows overwrites readFds with 0. Reset the fd here for next select call */ + Windows overwrites readFds with 0. Reset the fd here + for next select call */ if (rc == 0) { FD_SET(sshFd, &readFds); } @@ -1065,15 +1081,17 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh, rc = wolfSSH_get_error(ssh); if (rc == WS_CHAN_RXD) { if (lastChannel == shellChannelId) { - cnt_r = wolfSSH_ChannelIdRead(ssh, shellChannelId, - shellBuffer, + cnt_r = wolfSSH_ChannelIdRead(ssh, + shellChannelId, shellBuffer, sizeof shellBuffer); if (cnt_r <= 0) break; pending = 0; - if (WriteFile(ptyIn, shellBuffer, cnt_r, &cnt_r, NULL) != TRUE) { + if (WriteFile(ptyIn, shellBuffer, cnt_r, &cnt_r, + NULL) != TRUE) { wolfSSH_Log(WS_LOG_INFO, - "[SSHD] Error writing to pipe for console"); + "[SSHD] Error writing to pipe for " + "console"); break; } } @@ -1090,7 +1108,8 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh, if (readPending) { WMEMSET(shellBuffer, 0, EXAMPLE_BUFFER_SZ); - if (ReadFile(ptyOut, shellBuffer, EXAMPLE_BUFFER_SZ, &cnt_r, NULL) != TRUE) { + if (ReadFile(ptyOut, shellBuffer, EXAMPLE_BUFFER_SZ, &cnt_r, + NULL) != TRUE) { wolfSSH_Log(WS_LOG_INFO, "[SSHD] Error reading from pipe for console"); break; @@ -1459,7 +1478,7 @@ static void* HandleConnection(void* arg) graceTime = wolfSSHD_AuthGetGraceTime(conn->auth); if (graceTime > 0) { #ifdef WIN32 - //@TODO SetTimer(NULL, NULL, graceTime, alarmCatch); + /* @TODO SetTimer(NULL, NULL, graceTime, alarmCatch); */ #else signal(SIGALRM, alarmCatch); alarm((unsigned int)graceTime); diff --git a/examples/sftpclient/sftpclient.c b/examples/sftpclient/sftpclient.c index 3cd51bc53..52b6b89f8 100644 --- a/examples/sftpclient/sftpclient.c +++ b/examples/sftpclient/sftpclient.c @@ -1339,11 +1339,11 @@ THREAD_RETURN WOLFSSH_THREAD sftpclient_test(void* args) WFREE(workingDir, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (ret == WS_SUCCESS) { if (wolfSSH_shutdown(ssh) != WS_SUCCESS) { - int rc; - rc = wolfSSH_get_error(ssh); + int rc; + rc = wolfSSH_get_error(ssh); - if (rc != WS_SOCKET_ERROR_E && rc != WS_EOF) - printf("error with wolfSSH_shutdown()\n"); + if (rc != WS_SOCKET_ERROR_E && rc != WS_EOF) + printf("error with wolfSSH_shutdown()\n"); } } WCLOSESOCKET(sockFd); diff --git a/ide/winvs/README.md b/ide/winvs/README.md index 14ce9df0f..9e6054b12 100644 --- a/ide/winvs/README.md +++ b/ide/winvs/README.md @@ -60,7 +60,7 @@ DLL in that directory. SSHD Service ----------- -Creating a new servie +Creating a new service `sc.exe create wolfSSHd binpath="D:\work\wolfssh\ide\winvs\Debug\x64\wolfsshd.exe -f -h -p "` Starting wolfSSHd service run the following command in an adminstrator power shell session: @@ -70,4 +70,4 @@ To stop the service run the following in an adminstrator power shell session: `sc.exe stop wolfSSHd` To delete the service run -`sc.exe delete wolfSSHd` \ No newline at end of file +`sc.exe delete wolfSSHd` diff --git a/ide/winvs/api-test/api-test.vcxproj.user b/ide/winvs/api-test/api-test.vcxproj.user deleted file mode 100644 index 23a5dce7e..000000000 --- a/ide/winvs/api-test/api-test.vcxproj.user +++ /dev/null @@ -1,19 +0,0 @@ - - - - WindowsLocalDebugger - PATH=$(wolfCryptDllDebug32);%PATH% - - - WindowsLocalDebugger - PATH=$(wolfCryptDllDebug64);%PATH% - - - WindowsLocalDebugger - PATH=$(wolfCryptDllRelease32);%PATH% - - - WindowsLocalDebugger - PATH=$(wolfCryptDllRelease64);%PATH% - - diff --git a/ide/winvs/client/client.vcxproj.user b/ide/winvs/client/client.vcxproj.user deleted file mode 100644 index 23a5dce7e..000000000 --- a/ide/winvs/client/client.vcxproj.user +++ /dev/null @@ -1,19 +0,0 @@ - - - - WindowsLocalDebugger - PATH=$(wolfCryptDllDebug32);%PATH% - - - WindowsLocalDebugger - PATH=$(wolfCryptDllDebug64);%PATH% - - - WindowsLocalDebugger - PATH=$(wolfCryptDllRelease32);%PATH% - - - WindowsLocalDebugger - PATH=$(wolfCryptDllRelease64);%PATH% - - diff --git a/ide/winvs/echoserver/echoserver.vcxproj.user b/ide/winvs/echoserver/echoserver.vcxproj.user deleted file mode 100644 index 23a5dce7e..000000000 --- a/ide/winvs/echoserver/echoserver.vcxproj.user +++ /dev/null @@ -1,19 +0,0 @@ - - - - WindowsLocalDebugger - PATH=$(wolfCryptDllDebug32);%PATH% - - - WindowsLocalDebugger - PATH=$(wolfCryptDllDebug64);%PATH% - - - WindowsLocalDebugger - PATH=$(wolfCryptDllRelease32);%PATH% - - - WindowsLocalDebugger - PATH=$(wolfCryptDllRelease64);%PATH% - - diff --git a/ide/winvs/include.am b/ide/winvs/include.am index d5a90eaf4..df1990fc4 100644 --- a/ide/winvs/include.am +++ b/ide/winvs/include.am @@ -7,16 +7,9 @@ EXTRA_DIST+= ide/winvs/wolfssh.sln EXTRA_DIST+= ide/winvs/wolfssh.props EXTRA_DIST+= ide/winvs/wolfssh/wolfssh.vcxproj EXTRA_DIST+= ide/winvs/api-test/api-test.vcxproj -EXTRA_DIST+= ide/winvs/api-test/api-test.vcxproj.user EXTRA_DIST+= ide/winvs/unit-test/unit-test.vcxproj -EXTRA_DIST+= ide/winvs/unit-test/unit-test.vcxproj.user EXTRA_DIST+= ide/winvs/client/client.vcxproj -EXTRA_DIST+= ide/winvs/client/client.vcxproj.user EXTRA_DIST+= ide/winvs/echoserver/echoserver.vcxproj -EXTRA_DIST+= ide/winvs/echoserver/echoserver.vcxproj.user EXTRA_DIST+= ide/winvs/testsuite/testsuite.vcxproj -EXTRA_DIST+= ide/winvs/testsuite/testsuite.vcxproj.user EXTRA_DIST+= ide/winvs/wolfsftp-client/wolfsftp-client.vcxproj -EXTRA_DIST+= ide/winvs/wolfsftp-client/wolfsftp-client.vcxproj.user EXTRA_DIST+= ide/winvs/wolfsshd/wolfsshd.vcxproj -EXTRA_DIST+= ide/winvs/wolfsshd/wolfsshd.vcxproj.user diff --git a/ide/winvs/testsuite/testsuite.vcxproj.user b/ide/winvs/testsuite/testsuite.vcxproj.user deleted file mode 100644 index 23a5dce7e..000000000 --- a/ide/winvs/testsuite/testsuite.vcxproj.user +++ /dev/null @@ -1,19 +0,0 @@ - - - - WindowsLocalDebugger - PATH=$(wolfCryptDllDebug32);%PATH% - - - WindowsLocalDebugger - PATH=$(wolfCryptDllDebug64);%PATH% - - - WindowsLocalDebugger - PATH=$(wolfCryptDllRelease32);%PATH% - - - WindowsLocalDebugger - PATH=$(wolfCryptDllRelease64);%PATH% - - diff --git a/ide/winvs/unit-test/unit-test.vcxproj.user b/ide/winvs/unit-test/unit-test.vcxproj.user deleted file mode 100644 index 23a5dce7e..000000000 --- a/ide/winvs/unit-test/unit-test.vcxproj.user +++ /dev/null @@ -1,19 +0,0 @@ - - - - WindowsLocalDebugger - PATH=$(wolfCryptDllDebug32);%PATH% - - - WindowsLocalDebugger - PATH=$(wolfCryptDllDebug64);%PATH% - - - WindowsLocalDebugger - PATH=$(wolfCryptDllRelease32);%PATH% - - - WindowsLocalDebugger - PATH=$(wolfCryptDllRelease64);%PATH% - - diff --git a/ide/winvs/wolfsftp-client/wolfsftp-client.vcxproj.user b/ide/winvs/wolfsftp-client/wolfsftp-client.vcxproj.user deleted file mode 100644 index ee6c1e37c..000000000 --- a/ide/winvs/wolfsftp-client/wolfsftp-client.vcxproj.user +++ /dev/null @@ -1,19 +0,0 @@ - - - - WindowsLocalDebugger - PATH=$(wolfCryptDllDebug32);%PATH% - - - WindowsLocalDebugger - PATH=$(wolfCryptDllDebug64);%PATH% - - - WindowsLocalDebugger - PATH=$(wolfCryptDllRelease32);%PATH% - - - WindowsLocalDebugger - PATH=$(wolfCryptDllRelease64);%PATH% - - diff --git a/ide/winvs/wolfsshd/wolfsshd.vcxproj.user b/ide/winvs/wolfsshd/wolfsshd.vcxproj.user deleted file mode 100644 index e9f3ec837..000000000 --- a/ide/winvs/wolfsshd/wolfsshd.vcxproj.user +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - WindowsLocalDebugger - - - - - WindowsLocalDebugger - - \ No newline at end of file diff --git a/src/wolfscp.c b/src/wolfscp.c index 46c6eaffc..aed1e66a9 100644 --- a/src/wolfscp.c +++ b/src/wolfscp.c @@ -2346,14 +2346,19 @@ static int FindNextDirEntry(ScpSendCtx* ctx) WMEMCPY(ctx->entry, realFileName, sz); ctx->entry[sz] = '\0'; } while ((ctx->entry != NULL) && - (WSTRNCMP(ctx->entry, ".", 1) == 0 || - WSTRNCMP(ctx->entry, "..", 2) == 0)); + (((WSTRLEN(ctx->entry) == 1) && WSTRNCMP(ctx->entry, ".", 1) == 0) || + ((WSTRLEN(ctx->entry) == 2) && WSTRNCMP(ctx->entry, "..", 2) == 0))); #else do { ctx->entry = WREADDIR(&ctx->currentDir->dir); } while ((ctx->entry != NULL) && - (WSTRNCMP(ctx->entry->d_name, ".", 1) == 0 || - WSTRNCMP(ctx->entry->d_name ,"..", 2) == 0)); + ( + ((WSTRLEN(ctx->entry->d_name) == 1) && + (WSTRNCMP(ctx->entry->d_name, ".", 1) == 0)) + || + ((WSTRLEN(ctx->entry->d_name) == 2) && + (WSTRNCMP(ctx->entry->d_name ,"..", 2) == 0)) + )); #endif return WS_SUCCESS;