8000 Fix incorrect integer conversion from int to uint16 in port forwarder by BagToad · Pull Request #12831 · cli/cli · GitHub
[go: up one dir, main page]

Skip to content

Fix incorrect integer conversion from int to uint16 in port forwarder#12831

Merged
williammartin merged 2 commits intotrunkfrom
fix/code-scanning-alert-137
Mar 4, 2026
Merged

Fix incorrect integer conversion from int to uint16 in port forwarder#12831
williammartin merged 2 commits intotrunkfrom
fix/code-scanning-alert-137

Conversation

@BagToad
Copy link
Member
@BagToad BagToad commented Mar 4, 2026

Summary

Use the existing convertIntToUint16 helper with bounds checking instead of a raw uint16() cast on remotePort in UpdatePortVisibility. This prevents potential integer overflow when the port value exceeds the uint16 range (0–65535).

Fixes https://github.com/cli/cli/security/code-scanning/137 (go/incorrect-integer-conversion, CWE-190, CWE-681).

Use the existing convertIntToUint16 helper with bounds checking instead
of a raw uint16() cast on remotePort in UpdatePortVisibility. This
prevents potential integer overflow when the port value exceeds the
uint16 range (0-65535).

Fixes code scanning alert #137 (go/incorrect-integer-conversion).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@BagToad BagToad requested a review from a team as a code owner March 4, 2026 03:54
Copilot AI review requested due to automatic review settings March 4, 2026 03:54
@BagToad BagToad requested review from babakks and williammartin March 4, 2026 03:55
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 fixes a potential integer overflow (go/incorrect-integer-conversion, CWE-190/681) in UpdatePortVisibility by replacing a direct uint16(remotePort) cast with a call to the existing convertIntToUint16 helper, which performs bounds checking and returns an error if the value is out of range (0–65535).

Changes:

  • Replaces the raw uint16(remotePort) cast in UpdatePortVisibility with a safe convertIntToUint16 call and error handling

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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@williammartin
Copy link
Member

I'm merging this without codespaces review since it seems obvious.

@williammartin williammartin merged commit 38c9975 into trunk Mar 4, 2026
11 checks passed
@williammartin williammartin deleted the fix/code-scanning-alert-137 branch March 4, 2026 12:01
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.

4 participants

0