Maintenance: RX/TX

1. Before attempting to resize the output buffer in PreparePacket, make
sure the length and index in the output buffer is consistent.
2. If SendPacket gets a general error back from the call to the transmit
I/O callback, flush the output buffer and return the general error
upstream.
pull/222/head
John Safranek 2019-12-03 14:55:55 -08:00
parent b8f18d9459
commit b9ca9824b2
No known key found for this signature in database
GPG Key ID: 8CE817DE0D3CCB4A
1 changed files with 7 additions and 0 deletions

View File

@ -1448,6 +1448,10 @@ int wolfSSH_SendPacket(WOLFSSH* ssh)
case WS_CBIO_ERR_CONN_CLOSE: /* peer closed connection */
ssh->isClosed = 1;
break;
case WS_CBIO_ERR_GENERAL:
ShrinkBuffer(&ssh->outputBuffer, 1);
FALL_THROUGH
}
return WS_SOCKET_ERROR_E;
}
@ -5288,6 +5292,9 @@ static int PreparePacket(WOLFSSH* ssh, word32 payloadSz)
if (ssh == NULL)
ret = WS_BAD_ARGUMENT;
if (ssh->outputBuffer.length < ssh->outputBuffer.idx)
ret = WS_OVERFLOW_E;
if (ret == WS_SUCCESS) {
word32 packetSz, usedSz, outputSz;
byte paddingSz;