Clean up a couple issues where building the code with a C++ reported build errors.

1. Typecasting the return from malloc.
2. strncpy() checking.
pull/277/head
John Safranek 2020-08-31 09:31:47 -07:00
parent 4b021fcfa0
commit 132a0a52f6
No known key found for this signature in database
GPG Key ID: 8CE817DE0D3CCB4A
2 changed files with 5 additions and 4 deletions

View File

@ -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);

View File

@ -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;
}