mirror of https://github.com/wolfSSL/wolfssh.git
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
parent
4b021fcfa0
commit
132a0a52f6
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue