Merge pull request #270 from JacobBarthelmeh/fuzz

add sanity check on amount requested to be sent
pull/273/head
John Safranek 2020-07-22 15:45:51 -07:00 committed by GitHub
commit 95ebbe9e59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -1456,7 +1456,16 @@ int wolfSSH_SendPacket(WOLFSSH* ssh)
}
while (ssh->outputBuffer.length > 0) {
int sent = ssh->ctx->ioSendCb(ssh,
int sent;
/* sanity check on amount requested to be sent */
if (ssh->outputBuffer.idx + ssh->outputBuffer.length >
ssh->outputBuffer.bufferSz) {
WLOG(WS_LOG_ERROR, "Bad buffer state");
return WS_BUFFER_E;
}
sent = ssh->ctx->ioSendCb(ssh,
ssh->outputBuffer.buffer + ssh->outputBuffer.idx,
ssh->outputBuffer.length, ssh->ioWriteCtx);