Skip to content

Use musl implementation of gethostbyname/gethostbyaddr functions. NFC #21067

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

Merged
merged 1 commit into from
Jan 12, 2024

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Jan 11, 2024

Instead of implementing these directly in JS, we now implement a much lower level lookup function and rely on musl for all the higher level stuff.

gethostbyname bottoms out in _emscripten_lookup_name and gethostbyaddr bottomrs out in getnameinfo

@sbc100 sbc100 force-pushed the gethostbyname branch 2 times, most recently from 036f25f to c5bc62c Compare January 11, 2024 21:38
@sbc100 sbc100 requested review from kripken and dschuff January 11, 2024 21:38

*canon = 0;
if (name) {
/* reject empty name and check len so it fits into temp bufs */
Copy link
Member

Choose a reason for hiding this comment

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

I see a check for an empty name, but where is it rejected? (It looks like we continue down and send null to UTF8ToString in JS, which is fine.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think we handle that case.. but also the old code didn't handle it either, so I'm temped to leave it as is. I think passing NULL to gethostbyname is most likely undefined behaviour and I suppose we don't have a test for it.

@sbc100 sbc100 force-pushed the gethostbyname branch 2 times, most recently from 576fe15 to f655248 Compare January 11, 2024 23:23
@sbc100 sbc100 requested a review from kripken January 11, 2024 23:28
Instead of implementing these directly in JS, we now implement
a much lower level lookup function and rely on musl for all the higher
level stuff.

`gethostbyname` bottoms out in `_emscripten_lookup_name` and
`gethostbyaddr` bottomrs out in `getnameinfo`
@sbc100 sbc100 enabled auto-merge (squash) January 12, 2024 05:44
@sbc100 sbc100 merged commit 528bedf into emscripten-core:main Jan 12, 2024
@sbc100 sbc100 deleted the gethostbyname branch January 12, 2024 05:57
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