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

Convert port with htons() in p_getaddrinfo() #4280

Merged
merged 1 commit into from Jun 27, 2017

Conversation

Projects
None yet
3 participants
@ids1024
Contributor

ids1024 commented Jun 23, 2017

sin_port should be in network byte order.

Convert port with htons() in p_getaddrinfo()
`sin_port` should be in network byte order.
@pks-t

This comment has been minimized.

Member

pks-t commented Jun 27, 2017

Thanks for this fix, looks good to me! @ethomson?

Just out of curiosity: on which platform did you experience problems with this?

@ids1024

This comment has been minimized.

Contributor

ids1024 commented Jun 27, 2017

Porting libgit2 to Redox OS (https://redox-os.org/), which at the moment has a very basic Berkeley sockets implementation.

So Redox's implementation could be incorrect, but the Posix standard states clearly that sin_port should be in network byte order, and of course atol returns in host byte order. It seems odd to me that this would be wrong though, since this presumably would mean that libgit2 is broken on little endian systems without getaddrinfo.

@ethomson

This comment has been minimized.

Member

ethomson commented Jun 27, 2017

Agree that this should be in network byte order. @ids1024 - I'm not surprised it was broken, this was added explicitly for AmigaOS and I'm pretty sure only ever used by them until now. AmigaOS is m68k and thus big endian (or so I would suspect by the name.)

@ids1024

This comment has been minimized.

Contributor

ids1024 commented Jun 27, 2017

Ah, AmigaOS. I thought it was probably something like that, but I wasn't sure what big endian platform the code would have been used with.

@pks-t pks-t merged commit f5f13b5 into libgit2:master Jun 27, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@pks-t

This comment has been minimized.

Member

pks-t commented Jun 27, 2017

So I'm merging this as we all seem to agree this is correct.

Thanks for your fixup! 🎆

@ids1024 ids1024 deleted the ids1024:htons branch Jun 28, 2017

@pks-t pks-t referenced this pull request Jan 12, 2018

Merged

v0.26.3 backports #4475

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment