[asterisk-dev] [Code Review] Add getnameinfo() to ast_sockaddr_resolve()

Simon Perreault simon.perreault at viagenie.ca
Tue May 3 15:31:35 CDT 2011


On 2011-05-03 16:23, Paul Belanger wrote:
>> getaddrinfo("1050", ...) should fail.
>
> Yes, I believe this is the actual issue, it resolves to 0.0.4.26:5060

You're right! Wow, I didn't know that this syntax was valid...

Ok, now we're on the same wave length.

> But as far as
> I can tell, 1050 is _not_ a valid hostname on the OS.

Right, it's not a valid *hostname*. But it's a valid *IP address*. You
see, from the point of view of getaddrinfo(), there is no difference
between the string "0.0.4.26" and the string "1050". Both are valid, and
both designate the same 32-bit IPv4 address. It is exactly as if the
user had written Dial(SIP/0.0.4.26) instead. So because this syntax is
actually valid, I don't think there is anything to fix here.

An idea: we could apply a check (regex?) on the host name and warn if it
"strange", e.g. only digits.

Simon
-- 
DTN made easy, lean, and smart --> http://postellation.viagenie.ca
NAT64/DNS64 open-source        --> http://ecdysis.viagenie.ca
STUN/TURN server               --> http://numb.viagenie.ca



More information about the asterisk-dev mailing list