Skip to content

fix only_v6() panic on windows #603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

zh-jq
Copy link

@zh-jq zh-jq commented Jul 6, 2025

I have encountered a panic case in only_v6 in github CI on windows:
https://github.com/bytedance/g3/actions/runs/16095794585/job/45418469197

The input buffer size (optlen) must be 4, and the output optlen may be 1. As the input optval is initialized to zero, it will be modified to nonzero when ipv6 only, so just use optval != 0 to get the result value.

@Thomasdezeeuw
Copy link
Collaborator

We tried this already, see #593 and #564, it fails on our Windows CI.

@zh-jq zh-jq force-pushed the only-v6 branch 3 times, most recently from f48798a to 0374c46 Compare July 6, 2025 13:21
@zh-jq
Copy link
Author

zh-jq commented Jul 6, 2025

We tried this already, see #593 and #564, it fails on our Windows CI.

It seems that the input buffer size must be 4 bytes, and the output optlen may be 1, so the check could be: it will be ipv6 only if any of the buffer bits are not zero.

@ChrisDenton
Copy link
Member

To be clear, getsockopt is enforcing that the input buffer is at least DWORD in size (aka 4 bytes) but is only writing a single BOOLEAN (1 byte) into the buffer. Therefore the assertion ends up being too strong for this particular case. This is somewhat surprising but is technically allowed by the API.

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