Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

"record overflow" when STARTTLS enabled #56

Open
seriyps opened this Issue · 0 comments

1 participant

@seriyps

I have gen_smtp server, started with options

    SMTPOpts = [[
                 {address, SmtpIP},
                 {port, SmtpPort},
                 {domain, MxDomain},
                 {sessionoptions, [{allow_bare_newlines, fix},
                                   {certfile, FullPath(TlsCert)},
                                   {keyfile, FullPath(TlsKey)}]}
               ]],

and handler with

handle_EHLO(_Hostname, Extensions, State) ->
    WithTlsExts = Extensions ++ [{"STARTTLS", true}],
    {ok, WithTlsExts, State}.

The strange thing is that I sometimes got errors like this

2013-12-17 23:33:37 =CRASH REPORT====
  crasher:
    initial call: gen_smtp_server_session:init/1
    pid: <0.27270.5>
    registered_name: []
    exception exit: {{badarg,[{erlang,byte_size,["record overflow"],[]},{binstr,strip,3,[{file,"src/binstr.erl"},{line,258}]},{gen_smtp_server_session,parse_request,1,[{file,"src/gen_smtp_server_session.erl"},{line,241}]},{gen_smtp_server_session,handle_info,2,[{file,"src/gen_smtp_server_session.erl"},{line,189}]},{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,607}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,227}]}]},[{gen_server,terminate,6,[{file,"gen_server.erl"},{line,747}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,227}]}]}

I think this happens when https://github.com/Vagabond/gen_smtp/blob/fd0426c46468c33c21332335c267ae6e13e01afb/src/gen_smtp_server_session.erl#L193 receives
{ssl_error, Socket, "record overflow"} instead of {ssl, Socket, Data}.
See http://tools.ietf.org/html/rfc2246#section-7.2.2 about "record overflow".

The strange thing is that error happens not immidiately, but after some commands have passed.
Also, this may happen with different clients / relays, sending emails to my gen_smtp. The same client may have successfull and not successful sessions. I mean, sometimes it connect and operate successfuly, but sometimes the same client may fail.

Sample session logs:

2013-12-14 01:58:13.575 [debug] <0.23562.4>@tm_smtp_handler:init:30 Connection from {213,79,65,42}
2013-12-14 01:58:13.739 [debug] <0.23562.4>@tm_smtp_handler:handle_RCPT:57 RCPT to <<"*******@dropmail.me">> not successfully
2013-12-14 01:58:13.741 [debug] <0.23562.4>@tm_smtp_handler:handle_RCPT:57 RCPT to <<"*******@dropmail.me">> not successfully
2013-12-14 01:58:13.742 [debug] <0.23562.4>@tm_smtp_handler:handle_RCPT:57 RCPT to <<"*********@dropmail.me">> not successfully
2013-12-14 01:58:13.743 [debug] <0.23562.4>@tm_smtp_handler:handle_RCPT:57 RCPT to <<"***********@dropmail.me">> not successfully
2013-12-14 01:58:13.744 [debug] <0.23562.4>@tm_smtp_handler:handle_RCPT:57 RCPT to <<"**********@dropmail.me">> not successfully
2013-12-14 01:58:13.745 [debug] <0.23562.4>@tm_smtp_handler:handle_RCPT:57 RCPT to <<"***********@dropmail.me">> not successfully
2013-12-14 01:58:13.746 [debug] <0.23562.4>@tm_smtp_handler:handle_RCPT:57 RCPT to <<"**********@dropmail.me">> not successfully
2013-12-14 01:58:13.747 [debug] <0.23562.4>@tm_smtp_handler:handle_RCPT:57 RCPT to <<"***********@dropmail.me">> not successfully
2013-12-14 01:58:13.849 [error] <0.23562.4> gen_server <0.23562.4> terminated with reason: bad argument in call to erlang:byte_size("record overflow") in binstr:strip/3 line 258
2013-12-14 01:58:13.870 [error] <0.23562.4> CRASH REPORT Process <0.23562.4> with 0 neighbours exited with reason: bad argument in call to erlang:byte_size("record overflow") in binstr:strip/3 line 258 in gen_server:terminate/6 line 747
2013-12-11 10:30:51.070 [debug] <0.21092.3>@tm_smtp_handler:init:30 Connection from {194,67,246,9}
2013-12-11 10:30:51.207 [debug] <0.21092.3>@tm_smtp_handler:handle_RCPT:57 RCPT to <<"*****@dropmail.me">> not successfully
2013-12-11 10:30:51.400 [error] <0.21092.3> gen_server <0.21092.3> terminated with reason: bad argument in call to erlang:byte_size("record overflow") in binstr:strip/3 line 258
2013-12-11 10:30:51.583 [error] <0.21092.3> CRASH REPORT Process <0.21092.3> with 0 neighbours exited with reason: bad argument in call to erlang:byte_size("record overflow") in binstr:strip/3 line 258 in gen_server:terminate/6 line 747
2013-12-11 11:17:33.098 [debug] <0.21514.3>@tm_smtp_handler:init:30 Connection from {194,67,246,9}
2013-12-11 11:17:33.234 [debug] <0.21514.3>@tm_smtp_handler:handle_RCPT:57 RCPT to <<"****@dropmail.me">> not successfully
2013-12-11 11:17:33.314 [error] <0.21514.3> gen_server <0.21514.3> terminated with reason: bad argument in call to erla
ng:byte_size("record overflow") in binstr:strip/3 line 258
2013-12-11 11:17:33.317 [error] <0.21514.3> CRASH REPORT Process <0.21514.3> with 0 neighbours exited with reason: bad argument in call to erlang:byte_size("record overflow") in binstr:strip/3 line 258 in gen_server:terminate/6 line 747
2013-12-11 11:17:45.871 [debug] <0.21516.3>@tm_smtp_handler:init:30 Connection from {194,67,246,9}
2013-12-11 11:17:46.004 [debug] <0.21516.3>@tm_smtp_handler:handle_RCPT:57 RCPT to <<"******@dropmail.me">> not successfully
2013-12-11 11:17:46.117 [error] <0.21516.3> gen_server <0.21516.3> terminated with reason: bad argument in call to erlang:byte_size("record overflow") in binstr:strip/3 line 258
2013-12-11 11:17:46.118 [error] <0.21516.3> CRASH REPORT Process <0.21516.3> with 0 neighbours exited with reason: bad argument in call to erlang:byte_size("record overflow") in binstr:strip/3 line 258 in gen_server:terminate/6 line 747
2013-12-11 11:17:46.713 [debug] <0.21518.3>@tm_smtp_handler:init:30 Connection from {194,67,246,9}
2013-12-11 11:17:46.855 [debug] <0.21518.3>@tm_smtp_handler:handle_RCPT:57 RCPT to <<"*****@10mail.org">> not successfully
2013-12-11 11:17:47.311 [debug] <0.21520.3>@tm_smtp_handler:init:30 Connection from {194,67,246,9}
2013-12-11 11:17:47.444 [debug] <0.21520.3>@tm_smtp_handler:handle_RCPT:57 RCPT to <<"******@10mail.org">> not successful

Erlang R15B01, gen_smtp seriyps@8f6ae4f

I'm not sure if it's exactly gen_smtp issue or just buggy client, but gen_smtp may at least handle {ssl_error, Socket, Reason} and {tcp_error, Socket, Reason} more explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.