Skip to content

Conversation

yamt
Copy link
Collaborator

@yamt yamt commented Jul 9, 2025

some getaddrinfo implementations sometimes return results with ai_protocol=0.

cf. apache/nuttx#16693

standard-wise, i couldn't find anything about ai_protocol in susv4-2018 except the following text:

The fields ai_family, ai_socktype, and ai_protocol shall be usable
as the arguments to the socket() function to create a socket suitable
for use with the returned address.

because ai_protocol is usually merely used to feed socket() and socket() usually accepts 0, it's probably standard-wise ok for getaddrinfo to return ai_protocol=0.
the major implementations of getaddrinfo (eg. kame) seem to return specific values like ai_protocol=IPPROTO_TCP though.

anyway, for the purpose of this function, there is little point to be strict on the host getaddrinfo behavior. this commit just relaxes the check to be friendly to those getaddrinfo implementations.

some getaddrinfo implementations sometimes return results with
ai_protocol=0.

cf. apache/nuttx#16693

standard-wise, i couldn't find anything about ai_protocol in
susv4-2018 except the following text:

> The fields ai_family, ai_socktype, and ai_protocol shall be usable
> as the arguments to the socket() function to create a socket suitable
> for use with the returned address.

because ai_protocol is usually merely used to feed socket() and
socket() usually accepts 0, it's probably standard-wise ok for
getaddrinfo to return ai_protocol=0.
the major implementations of getaddrinfo (eg. kame) seem to return
specific values like ai_protocol=IPPROTO_TCP though.

anyway, for the purpose of this function, there is little point to
be strict on the host getaddrinfo behavior. this commit just relaxes
the check to be friendly to those getaddrinfo implementations.
@lum1n0us lum1n0us merged commit 2c4a660 into bytecodealliance:main Jul 14, 2025
451 checks passed
@lum1n0us lum1n0us added the bug-fix Determine if this PR addresses a bug. It will be used by scripts to classify PRs. label Jul 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-fix Determine if this PR addresses a bug. It will be used by scripts to classify PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants