Skip to content

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

Merged
pks-t merged 1 commit into
libgit2:masterfrom
ids1024:htons
Jun 27, 2017
Merged

Convert port with htons() in p_getaddrinfo()#4280
pks-t merged 1 commit into
libgit2:masterfrom
ids1024:htons

Conversation

@ids1024
Copy link
Copy Markdown
Contributor

@ids1024 ids1024 commented Jun 23, 2017

sin_port should be in network byte order.

`sin_port` should be in network byte order.
@pks-t
Copy link
Copy Markdown
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
Copy link
Copy Markdown
Contributor Author

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
Copy link
Copy Markdown
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
Copy link
Copy Markdown
Contributor Author

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
@pks-t
Copy link
Copy Markdown
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 htons branch June 28, 2017 03:27
@pks-t pks-t added the backport label Jan 11, 2018
@pks-t pks-t mentioned this pull request Jan 12, 2018
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