Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,9 @@ const char* GetErrorString(int err)
case WS_KDF_E:
return "KDF error";

case WS_DISCONNECT:
return "peer sent disconnect";

default:
return "Unknown error code";
}
Expand Down Expand Up @@ -5758,6 +5761,9 @@ static int KeyAgree_client(WOLFSSH* ssh, byte hashId, const byte* f, word32 fSz)
}


static INLINE byte SigTypeForId(byte id);


static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
{
struct wolfSSH_sigKeyBlock *sigKeyBlock_ptr = NULL;
Expand Down Expand Up @@ -6007,9 +6013,10 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
#ifndef WOLFSSH_NO_RSA
int tmpIdx = begin - sigSz;
#endif
/* Skip past the sig name. Check it, though. Other SSH
* implementations do the verify based on the name, despite what
* was agreed upon. XXX*/
const char* expectedSigName =
IdToName(SigTypeForId(ssh->handshake->pubKeyId));
word32 expectedSigNameSz = (word32)WSTRLEN(expectedSigName);

begin = 0;
ret = GetUint32(&scratch, sig, sigSz, &begin);
if (ret == WS_SUCCESS) {
Expand All @@ -6020,6 +6027,15 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
ret = WS_PARSE_E;
}
}
if (ret == WS_SUCCESS) {
if (scratch != expectedSigNameSz ||
WMEMCMP(sig + begin, expectedSigName, scratch) != 0) {
WLOG(WS_LOG_DEBUG,
"signature name %.*s did not match negotiated %s",
(int)scratch, sig + begin, expectedSigName);
Comment thread
LinuxJedi marked this conversation as resolved.
Outdated
ret = WS_PARSE_E;
}
}
if (ret == WS_SUCCESS) {
begin += scratch;
ret = GetUint32(&scratch, sig, sigSz, &begin);
Expand Down Expand Up @@ -6475,7 +6491,6 @@ static int DoDisconnect(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
const char* reasonStr = NULL;
word32 begin = *idx;

WOLFSSH_UNUSED(ssh);
WOLFSSH_UNUSED(len);
WOLFSSH_UNUSED(reasonStr);

Expand Down Expand Up @@ -6524,7 +6539,8 @@ static int DoDisconnect(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)

*idx = begin;

return WS_SUCCESS;
ssh->error = WS_DISCONNECT;
return WS_DISCONNECT;
}


Comment thread
LinuxJedi marked this conversation as resolved.
Expand Down Expand Up @@ -8707,19 +8723,19 @@ static int DoChannelOpen(WOLFSSH* ssh,
else {
const char *description = NULL;

if (fail_reason == OPEN_ADMINISTRATIVELY_PROHIBITED)
if (fail_reason == OPEN_OK) {
fail_reason = OPEN_ADMINISTRATIVELY_PROHIBITED;
description = "Channel open failed.";
}
else if (fail_reason == OPEN_ADMINISTRATIVELY_PROHIBITED)
Comment thread
LinuxJedi marked this conversation as resolved.
description = "Administratively prohibited.";
else if (fail_reason == OPEN_UNKNOWN_CHANNEL_TYPE)
description = "Channel type not supported.";
else if (fail_reason == OPEN_RESOURCE_SHORTAGE)
description = "Not enough resources.";

if (description != NULL) {
ret = SendChannelOpenFail(ssh, peerChannelId,
fail_reason, description, "en");
}
else
ret = SendRequestSuccess(ssh, 0); /* XXX Is this right? */
ret = SendChannelOpenFail(ssh, peerChannelId,
fail_reason, description, "en");
}

#ifdef WOLFSSH_FWD
Expand Down Expand Up @@ -10566,7 +10582,6 @@ static int PreparePacket(WOLFSSH* ssh, word32 payloadSz)
return ret;
}


static int BundlePacket(WOLFSSH* ssh)
{
byte* output = NULL;
Expand Down Expand Up @@ -17535,7 +17550,7 @@ int wolfSSH_oct2dec(WOLFSSH* ssh, byte* oct, word32 octSz)

for (i = 0; i < octSz; i++)
{
if (oct[i] < '0' || oct[0] > '7') {
if (oct[i] < '0' || oct[i] > '7') {
Comment thread
LinuxJedi marked this conversation as resolved.
ret = WS_BAD_ARGUMENT;
break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/wolfsftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4458,8 +4458,8 @@ int SFTP_RemoveHandleNode(WOLFSSH* ssh, byte* handle, word32 handleSz)
cur->prev->next = cur->next;
}

if (cur->next == NULL && cur->prev == NULL) {
ssh->handleList = NULL;
if (cur == ssh->handleList) {
ssh->handleList = cur->next;
}

WFREE(cur, ssh->ctx->heap, DYNTYPE_SFTP);
Comment thread
LinuxJedi marked this conversation as resolved.
Expand Down Expand Up @@ -4513,7 +4513,7 @@ static int SFTP_FreeHandles(WOLFSSH* ssh)
/* mktime() expects month from 0 to 11. Nucleus months
* are saved as 1 to 12. Hence 1 is being deducted to
* make it compatible with Unix time stamp. */
#define WS_GETMON(d) (_GETMON(d) - 5)
#define WS_GETMON(d) (_GETMON(d) - 1)
Comment thread
LinuxJedi marked this conversation as resolved.
#define WS_GETHOUR(t) (_GETHOUR(t) - 1)
Comment thread
dgarske marked this conversation as resolved.
Outdated
#else
#define WS_GETMON(d) _GETMON(d)
Expand Down
Loading
Loading