Uh oh!
There was an error while loading. Please reload this page.
Removed ntoa assumption on endianness - #42
Conversation
bremoran
commented
Feb 29, 2016
You're right that there's an assumption in this code: that all addresses are stored in big-endian order. This is not a processor assumption, it's an assumption made so that the API can be common across underlying stacks. Unfortunately, it's not documented; I've just raised an issue on this: #44. |
geky
commented
Feb 29, 2016
That assumption is broken: https://github.com/ARMmbed/sal/blob/master/source/inet_ntoa.c#L37 The following code changes behaviour based on your processor (in_addr_t is aliased to uint32_t): in_addr_t ia = socket_addr_get_ipv4_addr(&ina);
unsignedchar *ucp = (unsignedchar *)&ia;At the very least, inet_aton and inet_ntoa should not be asymmetric. |
bremoran
commented
Feb 29, 2016
In that case, |
geky
commented
Feb 29, 2016
Agreed, that's what this pull request fixes. Sorry if the title was poorly worded. |
bremoran
commented
Feb 29, 2016
I think I understand what's going on now. I'm inclined to mark @bogdanm what do you think? |
bogdanm
commented
Mar 1, 2016
Is it possible/easy to implement |
bremoran
commented
Mar 1, 2016
@bogdanm That might be viable, yes. They seem to have the same semantics when |
bremoran
commented
Mar 1, 2016
@geky: could you try again with this replacement for intinet_aton(constchar*cp, structsocket_addr*addr)
{
intrc=inet_pton(AF_INET, cp, addr);
return (rc==1 ? 1 : 0);
} |
This is a fix for what was a rather entertaining bug.
Even if it had worked, network code probably shouldn't be relying processor endianness.