From 614bd9dd723bc7f4d854adfc2ab8b475027297a9 Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Sat, 9 Dec 2017 22:39:43 +0300 Subject: Better process subtag decoding errors --- src/xmpp_stream_out.erl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/xmpp_stream_out.erl') diff --git a/src/xmpp_stream_out.erl b/src/xmpp_stream_out.erl index 33598497..8f4fa5c8 100644 --- a/src/xmpp_stream_out.erl +++ b/src/xmpp_stream_out.erl @@ -522,7 +522,7 @@ process_features(StreamFeatures, false -> TLSRequired = is_starttls_required(State1), TLSAvailable = is_starttls_available(State1), - case xmpp:get_subtag(StreamFeatures, #starttls{}) of + try xmpp:try_subtag(StreamFeatures, #starttls{}) of false when TLSRequired and not Encrypted -> Txt = <<"Use of STARTTLS required">>, send_pkt(State1, xmpp:serr_policy_violation(Txt, Lang)); @@ -543,14 +543,20 @@ process_features(StreamFeatures, case is_disconnected(State2) of true -> State2; false -> - case xmpp:get_subtag(StreamFeatures, #sasl_mechanisms{}) of + try xmpp:try_subtag(StreamFeatures, #sasl_mechanisms{}) of #sasl_mechanisms{list = Mechs} -> process_sasl_mechanisms(Mechs, State2); false -> process_sasl_failure( <<"Peer provided no SASL mechanisms">>, State2) + catch _:{xmpp_codec, Why} -> + Txt = xmpp:io_format_error(Why), + process_sasl_failure(Txt, State1) end end + catch _:{xmpp_codec, Why} -> + Txt = xmpp:io_format_error(Why), + process_sasl_failure(Txt, State1) end end. -- cgit v1.2.3