[erlang-bugs] Unexpected crash using inet_res:lookup/3

Daniel Luna <>
Fri Mar 9 21:55:46 CET 2012


Hi,

inet_res:lookup/3 normally doesn't crash for almost any input (see
examples 7-10 where I feed atoms and binaries to it).

But in the case of a string starting with period or a containing a
double period it will crash in inet_dns:encode_labels/4.

No mention of this being expected in the documentation so assume that
it's a bug.  See examples below.

Linux, R15B.

Cheers,

Daniel


Erlang R15B (erts-5.9) [source] [64-bit] [smp:5:5] [async-threads:0]
[kernel-poll:false]

Eshell V5.9  (abort with ^G)
1> inet_res:lookup("erlang.com", in, mx).
[{20,"mail.numbering.info"}]
2> inet_res:lookup("erlang..com", in, mx).
** exception error: no function clause matching
inet_dns:encode_labels(<<0,2,1,0,0,1,0,0,0,0,0,0,6,101,114,108,97,110,103>>,

{1,{[<<"erlang">>,<<>>,<<"com">>],12,nil,nil}},
                                                                       19,

[<<>>,<<"com">>]) (inet_dns.erl, line 693)
     in function  inet_dns:encode_name/4 (inet_dns.erl, line 674)
     in call from inet_dns:encode_query_section/3 (inet_dns.erl, line 268)
     in call from inet_dns:encode/1 (inet_dns.erl, line 239)
     in call from inet_res:make_query/5 (inet_res.erl, line 669)
     in call from inet_res:make_query/4 (inet_res.erl, line 637)
     in call from inet_res:res_query/5 (inet_res.erl, line 608)
     in call from inet_res:resolve/5 (inet_res.erl, line 141)
3> inet_res:lookup("..", in, mx).
** exception error: no function clause matching
inet_dns:encode_labels(<<0,3,1,0,0,1,0,0,0,0,0,0>>,{0,nil},12,[<<>>,<<>>])
(inet_dns.erl, line 693)
     in function  inet_dns:encode_name/4 (inet_dns.erl, line 674)
     in call from inet_dns:encode_query_section/3 (inet_dns.erl, line 268)
     in call from inet_dns:encode/1 (inet_dns.erl, line 239)
     in call from inet_res:make_query/5 (inet_res.erl, line 669)
     in call from inet_res:make_query/4 (inet_res.erl, line 637)
     in call from inet_res:res_query/5 (inet_res.erl, line 608)
     in call from inet_res:resolve/5 (inet_res.erl, line 141)
4> inet_res:lookup(".", in, mx).
[]
5> inet_res:lookup(".com", in, mx).
** exception error: no function clause matching
inet_dns:encode_labels(<<0,5,1,0,0,1,0,0,0,0,0,0>>,{0,nil},12,[<<>>,<<"com">>])
(inet_dns.erl, line 693)
     in function  inet_dns:encode_name/4 (inet_dns.erl, line 674)
     in call from inet_dns:encode_query_section/3 (inet_dns.erl, line 268)
     in call from inet_dns:encode/1 (inet_dns.erl, line 239)
     in call from inet_res:make_query/5 (inet_res.erl, line 669)
     in call from inet_res:make_query/4 (inet_res.erl, line 637)
     in call from inet_res:res_query/5 (inet_res.erl, line 608)
     in call from inet_res:resolve/5 (inet_res.erl, line 141)
6> inet_res:lookup("erlang.", in, mx).
[]
7> inet_res:lookup([1234567], in, mx).
[]
8> inet_res:lookup([atom], in, mx).
[]
9> inet_res:lookup(atom, in, mx).
[]
10> inet_res:lookup(<<"binary">>, in, mx).
[]


More information about the erlang-bugs mailing list