Skip to content

Fix f_518, f_519, f_871, f_1270#899

Open
yosuke-wolfssl wants to merge 4 commits intowolfSSL:masterfrom
yosuke-wolfssl:f_fix
Open

Fix f_518, f_519, f_871, f_1270#899
yosuke-wolfssl wants to merge 4 commits intowolfSSL:masterfrom
yosuke-wolfssl:f_fix

Conversation

@yosuke-wolfssl
Copy link
Contributor

This PR addresses f issues:

  • f_518: Correct the mask constant on case 30 to configure foreground color properly
  • f_519: Add the guard for findHandle on error path
  • f_871: Use GetSkip() in ParseRSAPubKey() and ParseECCPubKey() for bounds check
  • f_1270: Fix the length validation

@yosuke-wolfssl yosuke-wolfssl self-assigned this Mar 24, 2026
Copilot AI review requested due to automatic review settings March 24, 2026 04:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses several correctness issues across the Windows terminal handling, Windows filesystem porting layer, and internal packet/key parsing code.

Changes:

  • Fix Windows console foreground color masking for ANSI attribute case 30 (black foreground).
  • Harden Windows WS_FindFirstFileA() by using INVALID_HANDLE_VALUE and guarding output conversion/attribute access on failure.
  • Improve public key blob parsing bounds-safety by using GetSkip() in RSA/ECC public key parsing; adjust channel failure length validation.

Reviewed changes

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

File Description
src/wolfterm.c Corrects the bitmask used when clearing the foreground color bits for attribute 30.
src/port.c Uses INVALID_HANDLE_VALUE consistently and avoids reading/converting findFileData when FindFirstFileW() fails.
src/internal.c Uses GetSkip() to bounds-check skipping variable-length fields in RSA/ECC pubkey parsing; updates DoChannelFailure() length check (but currently introduces a parsing-consumption issue).
Comments suppressed due to low confidence (1)

src/internal.c:9409

  • After changing the length validation to allow non-zero payloads, this handler still doesn't consume or validate the expected fields of SSH_MSG_CHANNEL_FAILURE. The message payload should include at least the recipient channel ID (uint32), so leaving *idx unchanged will cause DoPacket() to not advance past the payload and corrupt subsequent packet parsing. Please parse/validate the recipient channel ID (and set/advance *idx accordingly), or at minimum advance *idx by len once the payload is accepted (and ideally reject unexpected lengths).
    if (ssh == NULL || buf == NULL || len == 0 || idx == NULL)
        ret = WS_BAD_ARGUMENT;

    if (ret == WS_SUCCESS)
        ret = WS_CHANOPEN_FAILED;

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

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.

2 participants