From ad07df0fa68f0351cd988ac39f9ba48fa9ff270b Mon Sep 17 00:00:00 2001 From: Sebastian Carpenter Date: Mon, 7 Jul 2025 09:35:51 -0600 Subject: [PATCH] rearranged evaluation of unsigned condition these two expressions were in danger of an underflow event --- src/internal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/internal.c b/src/internal.c index 60f802ce1..9855a8853 100644 --- a/src/internal.c +++ b/src/internal.c @@ -3227,7 +3227,7 @@ int wolfSSH_SendPacket(WOLFSSH* ssh) return WS_SOCKET_ERROR_E; } - while (ssh->outputBuffer.length - ssh->outputBuffer.idx > 0) { + while (ssh->outputBuffer.length > ssh->outputBuffer.idx) { int sent; /* sanity check on amount requested to be sent */ @@ -3237,7 +3237,7 @@ int wolfSSH_SendPacket(WOLFSSH* ssh) return WS_BUFFER_E; } - sent = ssh->ctx->ioSendCb(ssh, + sent = ssh->ctx->ioSendCb(ssh, ssh->outputBuffer.buffer + ssh->outputBuffer.idx, ssh->outputBuffer.length - ssh->outputBuffer.idx, ssh->ioWriteCtx); @@ -10002,7 +10002,7 @@ int DoReceive(WOLFSSH* ssh) } if (!aeadMode) { - if (ssh->curSz + UINT32_SZ - peerBlockSz > 0) { + if (ssh->curSz + UINT32_SZ > peerBlockSz) { ret = Decrypt(ssh, ssh->inputBuffer.buffer + ssh->inputBuffer.idx + peerBlockSz,