Skip to content
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

Fix Unix.getaddrinfo when called on strings containing null bytes #2100

Merged
merged 1 commit into from Oct 11, 2018

Conversation

Projects
None yet
3 participants
@Armael
Copy link
Member

commented Oct 10, 2018

utop # Unix.getaddrinfo "\000" "" [];;
Segmentation fault

(in batch mode, add a Gc.full_major() afterwards to crash the program)

This PR fixes a bug found and tracked down by Joe at the mirage hack retreat. Unix.getaddrinfo crashes the GC when called on a string containing null bytes because of a return that should be a CAMLreturn.

@Armael Armael force-pushed the Armael:getaddrinfo branch from 153144d to 90886f2 Oct 10, 2018

@shindere

This comment has been minimized.

Copy link
Contributor

commented Oct 10, 2018

@Armael Armael changed the title Fix Unix.getaddrinfo when called on strings containing zero bytes Fix Unix.getaddrinfo when called on strings containing null bytes Oct 10, 2018

@Armael Armael force-pushed the Armael:getaddrinfo branch from 90886f2 to f249c73 Oct 10, 2018

@Armael

This comment has been minimized.

Copy link
Member Author

commented Oct 10, 2018

Thanks for the review. I fixed the commit message as you said :).

@shindere

This comment has been minimized.

Copy link
Contributor

commented Oct 10, 2018

@gasche

This comment has been minimized.

Copy link
Member

commented Oct 10, 2018

Are there other unprotected uses of return in caml-exposed C functions?

@shindere

This comment has been minimized.

Copy link
Contributor

commented Oct 10, 2018

@Armael

This comment has been minimized.

Copy link
Member Author

commented Oct 11, 2018

My understanding is that using return in bindings is fine as long as the function is noalloc and hence does not use CAMLparam/CAMLlocal. So just grepping for return is not enough; maybe this could be a nice opportunity to use Coccinelle to check for the correct use of these macros?

@gasche gasche merged commit 4a02132 into ocaml:trunk Oct 11, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.