diff --git a/examples/echoserver/echoserver.c b/examples/echoserver/echoserver.c index 24405ae..c57a17c 100644 --- a/examples/echoserver/echoserver.c +++ b/examples/echoserver/echoserver.c @@ -588,12 +588,12 @@ static int shell_worker(thread_ctx_t* threadCtx) memset((void *)&buf_rx, 0, sizeof(buf_rx)); memset((void *)&buf_tx, 0, sizeof(buf_tx)); - buf_rx.buf = malloc(SE_BUF_SIZE); + buf_rx.buf = (char*)malloc(SE_BUF_SIZE); if (buf_rx.buf == NULL) { return WS_FATAL_ERROR; } - buf_tx.buf = malloc(SE_BUF_SIZE); + buf_tx.buf = (char*)malloc(SE_BUF_SIZE); if (buf_tx.buf == NULL) { free(buf_rx.buf); return WS_FATAL_ERROR; @@ -601,7 +601,7 @@ static int shell_worker(thread_ctx_t* threadCtx) #ifdef WOLFSSH_AGENT memset((void *)&agent_buf, 0, sizeof(agent_buf)); - agent_buf.buf = malloc(SE_BUF_SIZE); + agent_buf.buf = (char*)malloc(SE_BUF_SIZE); if (agent_buf.buf == NULL) { free(buf_rx.buf); free(buf_tx.buf); diff --git a/src/wolfscp.c b/src/wolfscp.c index 0ff1fcc..f974f68 100644 --- a/src/wolfscp.c +++ b/src/wolfscp.c @@ -2058,7 +2058,8 @@ int ScpPushDir(ScpSendCtx* ctx, const char* path, void* heap) } /* append directory name to ctx->dirName */ - WSTRNCPY(ctx->dirName, path, DEFAULT_SCP_FILE_NAME_SZ); + WSTRNCPY(ctx->dirName, path, DEFAULT_SCP_FILE_NAME_SZ-1); + ctx->dirName[DEFAULT_SCP_FILE_NAME_SZ-1] = '\0'; return WS_SUCCESS; }