Skip to content

Commit 11fa704

Browse files
authored
Merge pull request #740 from JacobBarthelmeh/static
static analysis report review
2 parents 3cabbdb + f092271 commit 11fa704

2 files changed

Lines changed: 21 additions & 17 deletions

File tree

src/internal.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,41 +1133,41 @@ void SshResourceFree(WOLFSSH* ssh, void* heap)
11331133

11341134
#ifdef WOLFSSH_SCP
11351135
if (ssh->scpConfirmMsg) {
1136-
WFREE(ssh->scpConfirmMsg, ssh->ctx->heap, DYNTYPE_STRING);
1136+
WFREE(ssh->scpConfirmMsg, heap, DYNTYPE_STRING);
11371137
ssh->scpConfirmMsg = NULL;
11381138
ssh->scpConfirmMsgSz = 0;
11391139
}
11401140
if (ssh->scpFileBuffer) {
11411141
ForceZero(ssh->scpFileBuffer, ssh->scpFileBufferSz);
1142-
WFREE(ssh->scpFileBuffer, ssh->ctx->heap, DYNTYPE_BUFFER);
1142+
WFREE(ssh->scpFileBuffer, heap, DYNTYPE_BUFFER);
11431143
ssh->scpFileBuffer = NULL;
11441144
ssh->scpFileBufferSz = 0;
11451145
}
11461146
if (ssh->scpFileName) {
1147-
WFREE(ssh->scpFileName, ssh->ctx->heap, DYNTYPE_STRING);
1147+
WFREE(ssh->scpFileName, heap, DYNTYPE_STRING);
11481148
ssh->scpFileName = NULL;
11491149
ssh->scpFileNameSz = 0;
11501150
}
11511151
if (ssh->scpRecvMsg) {
1152-
WFREE(ssh->scpRecvMsg, ssh->ctx->heap, DYNTYPE_STRING);
1152+
WFREE(ssh->scpRecvMsg, heap, DYNTYPE_STRING);
11531153
ssh->scpRecvMsg = NULL;
11541154
ssh->scpRecvMsgSz = 0;
11551155
}
11561156
#ifdef WOLFSSL_NUCLEUS
1157-
WFREE(ssh->scpBasePathDynamic, ssh->ctx->heap, DYNTYPE_BUFFER);
1157+
WFREE(ssh->scpBasePathDynamic, heap, DYNTYPE_BUFFER);
11581158
ssh->scpBasePathDynamic = NULL;
11591159
ssh->scpBasePathSz = 0;
11601160
#endif
11611161
#endif
11621162
#ifdef WOLFSSH_SFTP
11631163
if (ssh->sftpDefaultPath) {
1164-
WFREE(ssh->sftpDefaultPath, ssh->ctx->heap, DYNTYPE_STRING);
1164+
WFREE(ssh->sftpDefaultPath, heap, DYNTYPE_STRING);
11651165
ssh->sftpDefaultPath = NULL;
11661166
}
11671167
#endif
11681168
#ifdef WOLFSSH_TERM
11691169
if (ssh->modes) {
1170-
WFREE(ssh->modes, ssh->ctx->heap, DYNTYPE_STRING);
1170+
WFREE(ssh->modes, heap, DYNTYPE_STRING);
11711171
ssh->modesSz = 0;
11721172
}
11731173
#endif
@@ -2061,7 +2061,7 @@ int wolfSSH_ProcessBuffer(WOLFSSH_CTX* ctx,
20612061
int format, int type)
20622062
{
20632063
void* heap = NULL;
2064-
byte* der;
2064+
byte* der = NULL;
20652065
word32 derSz;
20662066
int wcType;
20672067
int ret = WS_SUCCESS;
@@ -2078,18 +2078,20 @@ int wolfSSH_ProcessBuffer(WOLFSSH_CTX* ctx,
20782078
return WS_BAD_FILETYPE_E;
20792079
}
20802080

2081-
if (type == BUFTYPE_CA) {
2081+
if (type == BUFTYPE_PRIVKEY) {
2082+
dynamicType = DYNTYPE_PRIVKEY;
2083+
wcType = PRIVATEKEY_TYPE;
2084+
}
2085+
#ifdef WOLFSSH_CERTS
2086+
else if (type == BUFTYPE_CA) {
20822087
dynamicType = DYNTYPE_CA;
20832088
wcType = CA_TYPE;
20842089
}
20852090
else if (type == BUFTYPE_CERT) {
20862091
dynamicType = DYNTYPE_CERT;
20872092
wcType = CERT_TYPE;
20882093
}
2089-
else if (type == BUFTYPE_PRIVKEY) {
2090-
dynamicType = DYNTYPE_PRIVKEY;
2091-
wcType = PRIVATEKEY_TYPE;
2092-
}
2094+
#endif
20932095
else {
20942096
return WS_BAD_ARGUMENT;
20952097
}
@@ -3406,6 +3408,10 @@ static int GetNameListRaw(byte* idList, word32* idListSz,
34063408
word32 nameSz = 0, nameListIdx = 0, idListIdx = 0;
34073409
int ret = WS_SUCCESS;
34083410

3411+
if (idList == NULL || nameList == NULL || idListSz == NULL) {
3412+
return WS_BAD_ARGUMENT;
3413+
}
3414+
34093415
/*
34103416
* The strings we want are now in the bounds of the message, and the
34113417
* length of the list. Find the commas, or end of list, and then decode
@@ -9868,7 +9874,7 @@ int SendKexInit(WOLFSSH* ssh)
98689874
if (ssh == NULL)
98699875
ret = WS_BAD_ARGUMENT;
98709876

9871-
if (ssh->ctx->side == WOLFSSH_ENDPOINT_SERVER &&
9877+
if (ret == WS_SUCCESS && ssh->ctx->side == WOLFSSH_ENDPOINT_SERVER &&
98729878
ssh->ctx->privateKeyCount == 0) {
98739879
WLOG(WS_LOG_DEBUG, "Server needs at least one private key");
98749880
ret = WS_BAD_ARGUMENT;

src/wolfscp.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,6 @@ int DoScpSource(WOLFSSH* ssh)
536536
break;
537537
}
538538

539-
continue;
540-
541539
case SCP_SEND_TIMESTAMP:
542540
WLOG(WS_LOG_DEBUG, scpState, "SCP_SEND_TIMESTAMP");
543541

@@ -1091,7 +1089,7 @@ static int ScpCheckForRename(WOLFSSH* ssh, int cmdSz)
10911089
int sz = (int)WSTRLEN(ssh->scpBasePath);
10921090
int idx;
10931091

1094-
if (sz > (int)sizeof(buf)) {
1092+
if (sz >= DEFAULT_SCP_MSG_SZ) {
10951093
return WS_BUFFER_E;
10961094
}
10971095

0 commit comments

Comments
 (0)