Merge pull request #114 from ejohnstown/static-fixes

Static Analysis Fixes
pull/116/head
JacobBarthelmeh 2018-11-15 15:44:03 -07:00 committed by GitHub
commit 3b629091f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 12 deletions

View File

@ -114,7 +114,7 @@ static int wsUserAuth(byte authType,
void* ctx)
{
const char* defaultPassword = (const char*)ctx;
word32 passwordSz;
word32 passwordSz = 0;
int ret = WOLFSSH_USERAUTH_SUCCESS;
(void)authType;
@ -133,8 +133,8 @@ static int wsUserAuth(byte authType,
char* c = strpbrk((char*)userPassword, "\r\n");;
if (c != NULL)
*c = '\0';
passwordSz = (word32)strlen((const char*)userPassword);
}
passwordSz = (word32)strlen((const char*)userPassword);
SetEcho(1);
#ifdef USE_WINDOWS_API
printf("\r\n");

View File

@ -1846,6 +1846,7 @@ static int DoKexInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
* is save the actual values.
*/
if (ret == WS_SUCCESS) {
if (ssh->handshake == NULL) {
ssh->handshake = HandshakeInfoNew(ssh->ctx->heap);
if (ssh->handshake == NULL) {
@ -1853,6 +1854,7 @@ static int DoKexInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
ret = WS_MEMORY_E;
}
}
}
if (ret == WS_SUCCESS) {
begin = *idx;

View File

@ -865,7 +865,7 @@ int wolfSSH_SetChannelType(WOLFSSH* ssh, byte type, byte* name, word32 nameSz)
int wolfSSH_SetUsername(WOLFSSH* ssh, const char* username)
{
char* value = NULL;
word32 valueSz;
word32 valueSz = 0;
int ret = WS_SUCCESS;
if (ssh == NULL || ssh->handshake == NULL ||

View File

@ -136,10 +136,10 @@ static int SFTP_ServerRecvInit(WOLFSSH* ssh) {
if (sz > 0) {
byte* data = (byte*)WMALLOC(sz, NULL, DYNTYPE_BUFFER);
if (data == NULL) return WS_MEMORY_E;
if ((len = wolfSSH_stream_read(ssh, data, sz)) != (int)sz) {
return len;
}
len = wolfSSH_stream_read(ssh, data, sz);
WFREE(data, NULL, DYNTYPE_BUFFER);
if (len != (int)sz)
return len;
}
ssh->reqId++;
@ -903,6 +903,7 @@ int wolfSSH_SFTP_RecvOpenDir(WOLFSSH* ssh, int reqId, word32 maxSz)
DYNTYPE_SFTP);
if (dirList == NULL) {
WFREE(dir, ssh->ctx->heap, DYNTYPE_BUFFER);
WCLOSEDIR(&ctx);
return WS_MEMORY_E;
}
#ifdef WOLFSSL_NUCLEUS
@ -922,6 +923,7 @@ int wolfSSH_SFTP_RecvOpenDir(WOLFSSH* ssh, int reqId, word32 maxSz)
ssh->ctx->heap, DYNTYPE_SFTP);
if (cur == NULL) {
WFREE(dir, ssh->ctx->heap, DYNTYPE_BUFFER);
WCLOSEDIR(&ctx);
return WS_MEMORY_E;
}
#ifdef WOLFSSL_NUCLEUS

View File

@ -49,7 +49,7 @@ static int Base16_Decode(const byte* in, word32 inLen,
word32 outIdx = 0;
if (inLen == 1 && *outLen && in) {
byte b = in[inIdx++] - 0x30; /* 0 starts at 0x30 */
byte b = in[inIdx] - 0x30; /* 0 starts at 0x30 */
/* sanity check */
if (b >= sizeof(hexDecode)/sizeof(hexDecode[0]))

View File

@ -259,8 +259,8 @@ static int wsUserAuth(byte authType,
char* c = strpbrk((char*)userPassword, "\r\n");;
if (c != NULL)
*c = '\0';
passwordSz = (word32)strlen((const char*)userPassword);
}
passwordSz = (word32)strlen((const char*)userPassword);
SetEcho(1);
#ifdef USE_WINDOWS_API
printf("\r\n");
@ -308,6 +308,8 @@ int doCmds()
if (pt[0] != '/') {
int maxSz = (int)WSTRLEN(workingDir) + sz + 2;
f = XMALLOC(maxSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (f == NULL)
return WS_MEMORY_E;
f[0] = '\0';
WSTRNCAT(f, workingDir, maxSz);