1. Fix allocation for UNICODE strings. Need to be (count+1)*2 octets.

2. Added a local dynamic memory type in the ports for strings.
3. Removed the includes for winsock2.h. It is included by windows.h.
4. In the example client, switched fin and fout to macros to stdin and
stdout. While they are FILE in POSIX, in Windows they are a function.
pull/134/head
John Safranek 2019-01-25 11:45:46 -08:00
parent f2cb7a3356
commit 5512128aa5
4 changed files with 11 additions and 12 deletions

View File

@ -37,8 +37,8 @@ int doCmds(void);
/* static so that signal handler can access and interrupt get/put */
static WOLFSSH* ssh = NULL;
static char* workingDir;
WFILE* fin;
WFILE* fout;
#define fin stdin
#define fout stdout
static void myStatusCb(WOLFSSH* sshIn, long bytes, char* name)
@ -327,9 +327,6 @@ int doCmds()
byte resume = 0;
int i;
fin = stdin ;
fout = stdout ;
while (!quit) {
char msg[WOLFSSH_MAX_FILENAME * 2];
char* pt;

View File

@ -149,7 +149,8 @@ void* WS_CreateFileA(const char* fileName, unsigned long desiredAccess,
if (error)
return INVALID_HANDLE_VALUE;
unicodeFileName = (wchar_t*)WMALLOC(unicodeFileNameSz, heap, 0);
unicodeFileName = (wchar_t*)WMALLOC((unicodeFileNameSz+1)*sizeof(wchar_t),
heap, PORT_DYNTYPE_STRING);
if (unicodeFileName == NULL)
return INVALID_HANDLE_VALUE;
@ -181,7 +182,8 @@ void* WS_FindFirstFileA(const char* fileName,
if (error)
return INVALID_HANDLE_VALUE;
unicodeFileName = (wchar_t*)WMALLOC(unicodeFileNameSz, heap, 0);
unicodeFileName = (wchar_t*)WMALLOC((unicodeFileNameSz+1)*sizeof(wchar_t),
heap, PORT_DYNTYPE_STRING);
if (unicodeFileName == NULL)
return INVALID_HANDLE_VALUE;
@ -237,7 +239,8 @@ int WS_GetFileAttributesExA(const char* fileName, void* fileInfo, void* heap)
if (error != 0)
return 0;
unicodeFileName = (wchar_t*)WMALLOC(unicodeFileNameSz, heap, 0);
unicodeFileName = (wchar_t*)WMALLOC((unicodeFileNameSz+1)*sizeof(wchar_t),
heap, PORT_DYNTYPE_STRING);
if (unicodeFileName == NULL)
return 0;

View File

@ -35,6 +35,9 @@
extern "C" {
#endif
#define PORT_DYNTYPE_STRING 12
/* This value needs to stay in sync with the actual value of DYNTYPE_STRING
* from internal.h. */
/* setup memory handling */
#ifndef WMALLOC_USER
@ -442,9 +445,6 @@ extern "C" {
#endif /* NO_WOLFSSH_DIR */
#elif defined(USE_WINDOWS_API)
#ifdef _WIN32_WCE
#include <winsock2.h>
#endif
#include <windows.h>
#ifndef _WIN32_WCE
#include <sys/types.h>

View File

@ -12,7 +12,6 @@
/*#include <wolfssh/error.h>*/
#ifdef USE_WINDOWS_API
#include <winsock2.h>
#ifndef _WIN32_WCE
#include <process.h>
#endif