[erlang-questions] is inet:gethostbyname( IP ) correct?

caio ariede caio.ariede@REDACTED
Tue Oct 13 21:06:37 CEST 2009


Interesting case.

The result doesn't appear to be an issue, but a feature of the gethostbyname
original implementation, in C code.

You get the same result, testing with PHP:

$ php -r 'var_dump(gethostbyname("12.27"));'
string(9) "12.0.0.27"

And other interesting results:

$ php -r 'var_dump(gethostbyname("255.2.256"));'
string(9) "255.2.1.0"

But I can't see where it's really useful.

Caio Ariede
http://caioariede.com/


On Tue, Oct 13, 2009 at 3:15 PM, Garry Hodgson <garry@REDACTED>wrote:

> recently, a bug in my code caused us to pass a string
> representing a floating point number to inet:gethostbyname().
> i would have expected it to return an error, but instead it
> returned an ip address, but one that made no sense to me:
>
> 1> inet:gethostbyname( '12.27' ).
> {ok,{hostent,"12.27",[],inet,4,[{12,0,0,27}]}}
>
> so my question is, is this behavior correct, and if so, what
> exactly does it mean that a lookup of '12.27' maps to '12.0.0.27'?
>
> thanks
>
> --
> Garry Hodgson
> Lead Member of Technical Staff
> AT&T Chief Security Office (CSO)
>
> "This e-mail and any files transmitted with it are AT&T property, are
> confidential, and are intended solely for the use of the individual or
> entity to whom this e-mail is addressed. If you are not one of the named
> recipient(s) or otherwise have reason to believe that you have received this
> message in error, please notify the sender and delete this message
> immediately from your computer. Any other use, retention, dissemination,
> forwarding, printing, or copying of this e-mail is strictly prohibited."
>
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
>
>


More information about the erlang-questions mailing list