Merge pull request #337 from ejohnstown/purgepacket

PurgePacket
pull/338/head
JacobBarthelmeh 2021-05-06 00:55:38 +07:00 committed by GitHub
commit cd6cb0dd36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 0 deletions

View File

@ -6267,6 +6267,15 @@ static int BundlePacket(WOLFSSH* ssh)
}
static void PurgePacket(WOLFSSH* ssh)
{
ssh->packetStartIdx = 0;
ssh->outputBuffer.idx = 0;
ssh->outputBuffer.plainSz = 0;
ShrinkBuffer(&ssh->outputBuffer, 1);
}
static INLINE void CopyNameList(byte* buf, word32* idx,
const char* src, word32 srcSz)
{
@ -6505,6 +6514,9 @@ int SendKexInit(WOLFSSH* ssh)
if (ret == WS_SUCCESS)
ret = wolfSSH_SendPacket(ssh);
if (ret != WS_WANT_WRITE && ret != WS_SUCCESS)
PurgePacket(ssh);
WLOG(WS_LOG_DEBUG, "Leaving SendKexInit(), ret = %d", ret);
return ret;
}
@ -7238,6 +7250,9 @@ int SendKexDhReply(WOLFSSH* ssh)
if (ret == WS_SUCCESS)
ret = SendNewKeys(ssh);
if (ret != WS_WANT_WRITE && ret != WS_SUCCESS)
PurgePacket(ssh);
WLOG(WS_LOG_DEBUG, "Leaving SendKexDhReply(), ret = %d", ret);
#ifdef WOLFSSH_SMALL_STACK
if (sigKeyBlock_ptr)
@ -8600,6 +8615,9 @@ int SendUserAuthRequest(WOLFSSH* ssh, byte authId, int addSig)
if (ret == WS_SUCCESS)
ret = wolfSSH_SendPacket(ssh);
if (ret != WS_WANT_WRITE && ret != WS_SUCCESS)
PurgePacket(ssh);
ForceZero(&authData, sizeof(WS_UserAuthData));
WLOG(WS_LOG_DEBUG, "Leaving SendUserAuthRequest(), ret = %d", ret);
#ifdef WOLFSSH_SMALL_STACK