Skip to content

Test DoChannelWindowAdjust overflow guard#1057

Open
ejohnstown wants to merge 1 commit into
wolfSSL:masterfrom
ejohnstown:windowadjust-test
Open

Test DoChannelWindowAdjust overflow guard#1057
ejohnstown wants to merge 1 commit into
wolfSSL:masterfrom
ejohnstown:windowadjust-test

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

Adds unit coverage for the overflow guard in DoChannelWindowAdjust, which rejects a peer window adjustment that would wrap peerWindowSz past UINT32_MAX with WS_OVERFLOW_E. The guard existed but was untested. (F-2874)

Test-only; no production behavior changes.

- Add test_DoChannelWindowAdjust_overflow via new
  wolfSSH_TestDoChannelWindowAdjust wrapper.
- Seed non-zero peer window, feed bytesToAdd = UINT32_MAX,
  assert WS_OVERFLOW_E with window unchanged.
- Feed a fitting value, assert window advances.
- Covers the guard so flipping or deleting it now fails.

Issue: F-2874
Copilot AI review requested due to automatic review settings June 24, 2026 00:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds internal unit test coverage for the existing overflow guard in DoChannelWindowAdjust (rejecting peer window adjustments that would wrap peerWindowSz past UINT32_MAX with WS_OVERFLOW_E). This fits into wolfSSH’s internal test strategy by exposing otherwise-static message handlers via wolfSSH_Test* wrappers and validating edge/boundary behavior.

Changes:

  • Expose DoChannelWindowAdjust to internal unit tests via a new wolfSSH_TestDoChannelWindowAdjust() wrapper.
  • Add a new unit test that validates overflow rejection, success on safe increments, and the exact boundary case.
  • Register the new unit test in the unit test runner.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
wolfssh/internal.h Declares the new internal-test wrapper prototype behind WOLFSSH_TEST_INTERNAL.
src/internal.c Implements wolfSSH_TestDoChannelWindowAdjust() to call the static handler.
tests/unit.c Adds and runs test_DoChannelWindowAdjust_overflow() covering overflow + boundary behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ejohnstown ejohnstown marked this pull request as ready for review June 24, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants