Skip to content

Commit 05ec832

Browse files
committed
Check bounds on addition with value from peer
Bounds check the bytes to add from the peer against the window size. Affected function: DoChannelWindowAdjust.
1 parent c802a7f commit 05ec832

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/internal.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#endif
3131

3232
#include <stdio.h>
33+
#include <stdint.h>
3334
#include <wolfssh/ssh.h>
3435
#include <wolfssh/internal.h>
3536
#include <wolfssh/log.h>
@@ -9469,11 +9470,15 @@ static int DoChannelWindowAdjust(WOLFSSH* ssh,
94699470
WLOG(WS_LOG_INFO, " peerWindowSz = %u",
94709471
channel->peerWindowSz);
94719472

9472-
channel->peerWindowSz += bytesToAdd;
9473-
9474-
WLOG(WS_LOG_INFO, " update peerWindowSz = %u",
9475-
channel->peerWindowSz);
9476-
9473+
if (bytesToAdd > UINT32_MAX - channel->peerWindowSz) {
9474+
ret = WS_OVERFLOW_E;
9475+
WLOG(WS_LOG_DEBUG, "peer window adjust would overflow");
9476+
}
9477+
else {
9478+
channel->peerWindowSz += bytesToAdd;
9479+
WLOG(WS_LOG_INFO, " update peerWindowSz = %u",
9480+
channel->peerWindowSz);
9481+
}
94779482
}
94789483
}
94799484

0 commit comments

Comments
 (0)